From: Vlastimil Babka <vbabka@suse.cz> To: Hugh Dickins <hughd@google.com> Cc: akpm@linux-foundation.org, alex.shi@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, liwang@redhat.com, mgorman@techsingularity.net Subject: Re: [PATCH 2/2] mm, page_alloc: use unlikely() in task_capc() Date: Wed, 17 Jun 2020 11:55:07 +0200 [thread overview] Message-ID: <4a24f7af-3aa5-6e80-4ae6-8f253b562039@suse.cz> (raw) In-Reply-To: <alpine.LSU.2.11.2006161319030.1119@eggly.anvils> On 6/16/20 10:29 PM, Hugh Dickins wrote: > On Tue, 16 Jun 2020, Vlastimil Babka wrote: > >> Hugh noted that task_capc() could use unlikely(), as most of the time there is >> no capture in progress and we are in page freeing hot path. Indeed adding >> unlikely() redirects produces assembly that better matches the assumption and >> moves all the tests away from the hot path. >> >> I have also noticed that we don't need to test for cc->direct_compaction as the >> only place we set current->task_capture is compact_zone_order() which also >> always sets cc->direct_compaction true. >> >> Suggested-by: Hugh Dickins <hughd@google.com> >> Signed-off-by: Vlastimil Babka <vbabka@suse.cz> > > Acked-by: Hugh Dickins <hughd@googlecom> Thanks. > Thanks for pursuing these, Vlastimil: I'm glad you were able > to remove a test and branch instead of adding one as I had. > > One little thing, you've probably gone into this yourself and know > what you've written here is optimal: but I'd rather imagined it with > "unlikely(capc) && ..." instead of "unlikely(capc && ...)" - no need > to respond, please just give it a moment's consideration, Acked anyway. It makes no difference, at least on my gcc10 which seems to be smart enough to do the right thing. But yeah, your suggestion is more readable and precise and maybe can work better with a less smart compiler. Thanks. ----8<---- From 615eea6f6abe288ffb708aa0d1bdfbeaf30a4cbd Mon Sep 17 00:00:00 2001 From: Vlastimil Babka <vbabka@suse.cz> Date: Tue, 16 Jun 2020 10:14:47 +0200 Subject: [PATCH] mm, page_alloc: use unlikely() in task_capc() Hugh noted that task_capc() could use unlikely(), as most of the time there is no capture in progress and we are in page freeing hot path. Indeed adding unlikely() produces assembly that better matches the assumption and moves all the tests away from the hot path. I have also noticed that we don't need to test for cc->direct_compaction as the only place we set current->task_capture is compact_zone_order() which also always sets cc->direct_compaction true. Suggested-by: Hugh Dickins <hughd@google.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Hugh Dickins <hughd@googlecom> --- mm/page_alloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 48eb0f1410d4..18d5aed3f97b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -813,11 +813,10 @@ static inline struct capture_control *task_capc(struct zone *zone) { struct capture_control *capc = current->capture_control; - return capc && + return unlikely(capc) && !(current->flags & PF_KTHREAD) && !capc->page && - capc->cc->zone == zone && - capc->cc->direct_compaction ? capc : NULL; + capc->cc->zone == zone ? capc : NULL; } static inline bool -- 2.27.0
next prev parent reply other threads:[~2020-06-17 9:55 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-10 20:48 [PATCH] mm, page_alloc: capture page in task context only Hugh Dickins 2020-06-11 15:43 ` Mel Gorman 2020-06-12 10:30 ` Vlastimil Babka 2020-06-15 21:03 ` Hugh Dickins 2020-06-16 7:45 ` Vlastimil Babka 2020-06-16 8:26 ` [PATCH 1/2] mm, compaction: make capture control handling safe wrt interrupts Vlastimil Babka 2020-06-16 8:26 ` [PATCH 2/2] mm, page_alloc: use unlikely() in task_capc() Vlastimil Babka 2020-06-16 20:29 ` Hugh Dickins 2020-06-17 9:55 ` Vlastimil Babka [this message] 2020-06-22 8:58 ` Mel Gorman 2020-06-16 20:18 ` [PATCH 1/2] mm, compaction: make capture control handling safe wrt interrupts Hugh Dickins
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=4a24f7af-3aa5-6e80-4ae6-8f253b562039@suse.cz \ --to=vbabka@suse.cz \ --cc=akpm@linux-foundation.org \ --cc=alex.shi@linux.alibaba.com \ --cc=hughd@google.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=liwang@redhat.com \ --cc=mgorman@techsingularity.net \ --subject='Re: [PATCH 2/2] mm, page_alloc: use unlikely() in task_capc()' \ /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
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).