Subject: Re: linux-next: manual merge of the akpm-current tree with the block tree

From: Jens Axboe <[email-masked]>
Date: Thu, 18 Mar 2021 12:19:34 -0600

On 3/18/21 11:54 AM, Shakeel Butt wrote:
> On Wed, Mar 17, 2021 at 11:17 PM Stephen Rothwell <[email-masked]> wrote:
>>
>> Hi all,
>>
>> Today's linux-next merge of the akpm-current tree got a conflict in:
>>
>>   mm/memcontrol.c
>>
>> between commit:
>>
>>   06d69d4c8669 ("mm: Charge active memcg when no mm is set")
>>
>> from the block tree and commit:
>>
>>   674788258a66 ("memcg: charge before adding to swapcache on swapin")
>>
>> from the akpm-current tree.
>>
>> I fixed it up (I think - see below) and can carry the fix as necessary.
>> This is now fixed as far as linux-next is concerned, but any non trivial
>> conflicts should be mentioned to your upstream maintainer when your tree
>> is submitted for merging.  You may also want to consider cooperating
>> with the maintainer of the conflicting tree to minimise any particularly
>> complex conflicts.
>>
>> --
>> Cheers,
>> Stephen Rothwell
>>
>> diff --cc mm/memcontrol.c
>> index f05501669e29,668d1d7c2645..000000000000
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@@ -6691,65 -6549,73 +6550,80 @@@ out
>>    * @gfp_mask: reclaim mode
>>    *
>>    * Try to charge @page to the memcg that @mm belongs to, reclaiming
>>  - * pages according to @gfp_mask if necessary.
>>  + * pages according to @gfp_mask if necessary. if @mm is NULL, try to
>>  + * charge to the active memcg.
>>    *
>> +  * Do not use this for pages allocated for swapin.
>> +  *
>>    * Returns 0 on success. Otherwise, an error code is returned.
>>    */
>>   int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask)
>>   {
>> -       unsigned int nr_pages = thp_nr_pages(page);
>> -       struct mem_cgroup *memcg = NULL;
>> -       int ret = 0;
>> +       struct mem_cgroup *memcg;
>> +       int ret;
>>
>>         if (mem_cgroup_disabled())
>> -               goto out;
>> +               return 0;
>>
>> -       if (PageSwapCache(page)) {
>> -               swp_entry_t ent = { .val = page_private(page), };
>> -               unsigned short id;
>>  -      memcg = get_mem_cgroup_from_mm(mm);
>> ++      if (!mm) {
>> ++              memcg = get_mem_cgroup_from_current();
>> ++              if (!memcg)
>> ++                      memcg = get_mem_cgroup_from_mm(current->mm);
>> ++      } else {
>> ++              memcg = get_mem_cgroup_from_mm(mm);
>> ++      }
>> +       ret = __mem_cgroup_charge(page, memcg, gfp_mask);
>> +       css_put(&memcg->css);
> 
> Things are more complicated than this. First we need a similar change
> in mem_cgroup_swapin_charge_page() but I am thinking of making
> get_mem_cgroup_from_mm() more general and not make any changes in
> these two functions.
> 
> Is it possible to get Dan's patch series in mm tree? More specifically
> the above two patches in the same tree then one of us can make their
> patch rebase over the other (I am fine with doing this myself).

Yes, I think we should do that, and since he's going to be respinning
the series anyway, I'll drop it right now and then let's take it through
Andrew to avoid unnecessary complications that way.

-- 
Jens Axboe