[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200930103557.GQ2277@dhcp22.suse.cz>
Date: Wed, 30 Sep 2020 12:35:57 +0200
From: Michal Hocko <mhocko@...e.com>
To: Uladzislau Rezki <urezki@...il.com>
Cc: Vlastimil Babka <vbabka@...e.cz>,
LKML <linux-kernel@...r.kernel.org>, RCU <rcu@...r.kernel.org>,
linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
"Paul E . McKenney" <paulmck@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
"Theodore Y . Ts'o" <tytso@....edu>,
Joel Fernandes <joel@...lfernandes.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Oleksiy Avramchenko <oleksiy.avramchenko@...ymobile.com>,
Mel Gorman <mgorman@...hsingularity.net>
Subject: Re: [RFC-PATCH 2/4] mm: Add __rcu_alloc_page_lockless() func.
On Wed 30-09-20 00:07:42, Uladzislau Rezki wrote:
[...]
> <snip>
> bool is_pcp_cache_empty(gfp_t gfp)
> {
> struct per_cpu_pages *pcp;
> struct zoneref *ref;
> unsigned long flags;
> bool empty;
>
> ref = first_zones_zonelist(node_zonelist(
> numa_node_id(), gfp), gfp_zone(gfp), NULL);
> if (!ref->zone)
> return true;
>
> local_irq_save(flags);
> pcp = &this_cpu_ptr(ref->zone->pageset)->pcp;
> empty = list_empty(&pcp->lists[gfp_migratetype(gfp)]);
> local_irq_restore(flags);
>
> return empty;
> }
>
> disable_irq();
> if (!is_pcp_cache_empty(GFP_NOWAIT))
> __get_free_page(GFP_NOWAIT);
> enable_irq();
> <snip>
>
> Do you mean to have something like above? I mean some extra API
> function that returns true or false if fast-fast allocation can
> either occur or not. Above code works just fine and never touches
> main zone->lock.
The above code works with the _current_ implementation and it restricts
its implementation to some degree. Future changes might get harder to
implement with a pattern like this. I do not think we want users to be
aware of internal implementation details like pcp caches, migrate types
or others. While pcp caches are here for years and unlikely to change in
a foreseeable future many details are changing on regular basis.
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists