LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>, Roman Gushchin <guro@fb.com>, Michal Hocko <mhocko@suse.com>, Matthew Wilcox <willy@infradead.org>, linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>, Thomas Garnier <thgarnie@google.com>, Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>, Steven Rostedt <rostedt@goodmis.org>, Joel Fernandes <joelaf@google.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>, Tejun Heo <tj@kernel.org> Subject: Re: [PATCH 2/4] mm/vmap: preload a CPU with one object for split purpose Date: Thu, 23 May 2019 13:42:32 +0200 [thread overview] Message-ID: <20190523114232.unx6f6h4s4onb3cr@pc636> (raw) In-Reply-To: <20190522111904.ff2cd5011c8c3b3207e3f3fa@linux-foundation.org> On Wed, May 22, 2019 at 11:19:04AM -0700, Andrew Morton wrote: > On Wed, 22 May 2019 17:09:37 +0200 "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote: > > > Introduce ne_fit_preload()/ne_fit_preload_end() functions > > for preloading one extra vmap_area object to ensure that > > we have it available when fit type is NE_FIT_TYPE. > > > > The preload is done per CPU and with GFP_KERNEL permissive > > allocation masks, which allow to be more stable under low > > memory condition and high memory pressure. > > What is the reason for this change? Presumably some workload is > suffering from allocation failures? Please provide a full description > of when and how this occurs so others can judge the desirability of > this change. > It is not driven by any particular workload that suffers from it. At least i am not aware of something related to it. I just think about avoid of using GFP_NOWAIT if it is possible. The reason behind it is GFP_KERNEL has more permissive parameters and as an example does __GFP_DIRECT_RECLAIM if no memory available what can be beneficial in case of high memory pressure or low memory condition. Probably i could simulate some special conditions and come up with something, but i am not sure. I think this change will be good for "small" systems without swap under high memory pressure where direct reclaim and other flags can fix the situation. Do you want me to try to find a specific test case? What do you think? > > --- a/mm/vmalloc.c > > +++ b/mm/vmalloc.c > > @@ -364,6 +364,13 @@ static LIST_HEAD(free_vmap_area_list); > > */ > > static struct rb_root free_vmap_area_root = RB_ROOT; > > > > +/* > > + * Preload a CPU with one object for "no edge" split case. The > > + * aim is to get rid of allocations from the atomic context, thus > > + * to use more permissive allocation masks. > > + */ > > +static DEFINE_PER_CPU(struct vmap_area *, ne_fit_preload_node); > > + > > static __always_inline unsigned long > > va_size(struct vmap_area *va) > > { > > @@ -950,9 +957,24 @@ adjust_va_to_fit_type(struct vmap_area *va, > > * L V NVA V R > > * |---|-------|---| > > */ > > - lva = kmem_cache_alloc(vmap_area_cachep, GFP_NOWAIT); > > - if (unlikely(!lva)) > > - return -1; > > + lva = __this_cpu_xchg(ne_fit_preload_node, NULL); > > + if (unlikely(!lva)) { > > + /* > > + * For percpu allocator we do not do any pre-allocation > > + * and leave it as it is. The reason is it most likely > > + * never ends up with NE_FIT_TYPE splitting. In case of > > + * percpu allocations offsets and sizes are aligned to > > + * fixed align request, i.e. RE_FIT_TYPE and FL_FIT_TYPE > > + * are its main fitting cases. > > + * > > + * There are few exceptions though, as en example it is > > "a few" > > s/en/an/ > > > + * a first allocation(early boot up) when we have "one" > > s/(/ (/ > Will fix that. > > + * big free space that has to be split. > > + */ > > + lva = kmem_cache_alloc(vmap_area_cachep, GFP_NOWAIT); > > + if (!lva) > > + return -1; > > + } > > > > /* > > * Build the remainder. > > @@ -1023,6 +1045,50 @@ __alloc_vmap_area(unsigned long size, unsigned long align, > > } > > > > /* > > + * Preload this CPU with one extra vmap_area object to ensure > > + * that we have it available when fit type of free area is > > + * NE_FIT_TYPE. > > + * > > + * The preload is done in non-atomic context thus, it allows us > > s/ thus,/, thus/ > Will fix. > > + * to use more permissive allocation masks, therefore to be more > > s/, therefore// > Will fix. > > + * stable under low memory condition and high memory pressure. > > + * > > + * If success, it returns zero with preemption disabled. In case > > + * of error, (-ENOMEM) is returned with preemption not disabled. > > + * Note it has to be paired with alloc_vmap_area_preload_end(). > > + */ > > +static void > > +ne_fit_preload(int *preloaded) > > +{ > > + preempt_disable(); > > + > > + if (!__this_cpu_read(ne_fit_preload_node)) { > > + struct vmap_area *node; > > + > > + preempt_enable(); > > + node = kmem_cache_alloc(vmap_area_cachep, GFP_KERNEL); > > + if (node == NULL) { > > + *preloaded = 0; > > + return; > > + } > > + > > + preempt_disable(); > > + > > + if (__this_cpu_cmpxchg(ne_fit_preload_node, NULL, node)) > > + kmem_cache_free(vmap_area_cachep, node); > > + } > > + > > + *preloaded = 1; > > +} > > Why not make it do `return preloaded;'? The > pass-and-return-by-reference seems unnecessary? > Will rewrite. I just though about: preload_start(preloaded) ... preload_end(preloaded) instead of doing it conditionally: preloaded = preload_start() ... if (preloaded) preload_end(); Thank you! -- Vlad Rezki
next prev parent reply other threads:[~2019-05-23 11:42 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-22 15:09 [PATCH 1/4] mm/vmap: remove "node" argument Uladzislau Rezki (Sony) 2019-05-22 15:09 ` [PATCH 2/4] mm/vmap: preload a CPU with one object for split purpose Uladzislau Rezki (Sony) 2019-05-22 18:19 ` Andrew Morton 2019-05-23 11:42 ` Uladzislau Rezki [this message] 2019-05-22 15:09 ` [PATCH 3/4] mm/vmap: get rid of one single unlink_va() when merge Uladzislau Rezki (Sony) 2019-05-22 18:19 ` Andrew Morton 2019-05-23 11:49 ` Uladzislau Rezki 2019-05-22 15:09 ` [PATCH 4/4] mm/vmap: move BUG_ON() check to the unlink_va() Uladzislau Rezki (Sony) 2019-05-22 18:19 ` Andrew Morton 2019-05-23 12:07 ` Uladzislau Rezki [not found] ` <20190524103316.1352-1-hdanton@sina.com> 2019-05-24 14:14 ` [PATCH 2/4] mm/vmap: preload a CPU with one object for split purpose Uladzislau Rezki
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=20190523114232.unx6f6h4s4onb3cr@pc636 \ --to=urezki@gmail.com \ --cc=akpm@linux-foundation.org \ --cc=guro@fb.com \ --cc=joelaf@google.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mhocko@suse.com \ --cc=mingo@elte.hu \ --cc=oleksiy.avramchenko@sonymobile.com \ --cc=rostedt@goodmis.org \ --cc=tglx@linutronix.de \ --cc=thgarnie@google.com \ --cc=tj@kernel.org \ --cc=willy@infradead.org \ /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: linkBe 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; as well as URLs for NNTP newsgroup(s).