From: Pan Xinhui <xinhuix.pan@intel.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
vbabka@suse.cz, rientjes@google.com, hannes@cmpxchg.org,
nasa4836@gmail.com, mgorman@suse.de,
alexander.h.duyck@redhat.com, aneesh.kumar@linux.vnet.ibm.com,
"yanmin_zhang@linux.intel.com" <yanmin_zhang@linux.intel.com>
Subject: Re: [PATCH] gfp: GFP_RECLAIM_MASK should include __GFP_NO_KSWAPD
Date: Wed, 14 Oct 2015 16:36:13 +0800 [thread overview]
Message-ID: <561E13FD.2070206@intel.com> (raw)
In-Reply-To: <20151014074134.GD28333@dhcp22.suse.cz>
hello, Michal
thanks for your kind reply!
On 2015a1'10ae??14ae?JPY 15:41, Michal Hocko wrote:
> On Wed 14-10-15 13:58:05, Pan Xinhui wrote:
>> Hi, all
>> I am working on some debug features' development.
>> I use kmalloc in some places of *scheduler*.
>
> This sounds inherently dangerous.
>
that's how we found weird bugs. :)
>> And the gfp_flag is GFP_ATOMIC, code looks like
>> p = kmalloc(sizeof(*p), GFP_ATOMIC);
>>
>> however I notice GFP_ATOMIC is still not enough. because when system
>> is at low memory state, slub might try to wakeup kswapd. then some
>> weird issues hit.
>
> gfp flags have been reworked in the current mmotm tree so you want
> __GFP_ATOMIC here. This will be non sleeping allocation which won't even
> wake up kswapd. I guess you do not want/need to touch memory reserves
> for something like a debugging feature (so you do not have to abuse
> __GFP_HIGH)
>
In my debug patches, I need __GFP_HIGH.
There is one special test case, in boot stage, we will reserve a big range of memory, to try to detect if all drivers can handle low-memory in correct ways.
So maybe I need my own kmalloc succeed.
what I need to do now is just clear __GFP_KSWAPD_RECLAIM in kmalloc.
> [...]
>
>> After some simple check, I change my codes. this time code looks like:
>> p = kmalloc(sizeof(*p), GFP_ATOMIC | __GFP_NO_KSWAPD);
>> I think this flag will forbid slub to call any scheduler codes. But issue still hit. :(
>>
>> my test result shows that __GFP_NO_KSWAPD is cleared when slub pass gfp_flag to page allocator!!!
>>
>> at last I found it is clear by codes below.
>> 1441 static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
>> 1442 {
>> 1443 if (unlikely(flags & GFP_SLAB_BUG_MASK)) {
>> 1444 pr_emerg("gfp: %u\n", flags & GFP_SLAB_BUG_MASK);
>> 1445 BUG();
>> 1446 }
>> 1447
>> 1448 return allocate_slab(s,
>> 1449 flags & (GFP_RECLAIM_MASK | GFP_CONSTRAINT_MASK), node);//all other flags will be cleared. my god!!!
>> 1450 }
>>
>> I think GFP_RECLAIM_MASK should include as many available flags as possible. :)
>
> Not really. It should only contain those which are really reclaim
> related. The fact that SLUB drops other flags is an internal detail
> of the allocator. If the resulting memory doesn't match the original
> requirements (e.g. zone placing etc...) then it is certainly a bug
> but not a bug in GFP_RECLAIM_MASK.
>
oh, yes. thanks for explanation.
> Anyway you are right that GFP_RECLAIM_MASK should contain
> __GFP_NO_KSWAPD resp. its new representation which is the case in the
> current mmotm tree as pointed out in previous response.
>
I am glad to see someone has fix it, too :)
thanks
xinhui
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-10-14 8:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-14 5:36 Pan Xinhui
2015-10-14 5:58 ` Pan Xinhui
2015-10-14 7:41 ` Michal Hocko
2015-10-14 8:36 ` Pan Xinhui [this message]
2015-10-14 7:34 ` Michal Hocko
2015-10-14 8:17 ` Pan Xinhui
2015-10-14 8:38 ` Michal Hocko
2015-10-14 8:40 ` Pan Xinhui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561E13FD.2070206@intel.com \
--to=xinhuix.pan@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.h.duyck@redhat.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@kernel.org \
--cc=nasa4836@gmail.com \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
--cc=yanmin_zhang@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox