Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2728642ybt; Tue, 16 Jun 2020 13:34:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEkLtYy4pdHC9QATkHfNKiGJNr2uFKCSYur/B7RMsc3TtrSFD8CmbpIPxdULqLKx1S1gdP X-Received: by 2002:a17:906:2c44:: with SMTP id f4mr4624891ejh.183.1592339646514; Tue, 16 Jun 2020 13:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592339646; cv=none; d=google.com; s=arc-20160816; b=qXl9V3v1E77WdSl5uzhTwFS5rRWt2IFye4ENHhKHD8Z+Oy9R5m5rD4AkawOoL9Zbak VsZhlMHL6RcurMFBo7Zhn40gYXdBeNbLA/MnMY7l5+Ftp4nbpoa0E7LQgFXobxUPp2eL mlWwKNXLBlaaZObLAgzxFnsbYylV9AXDJZIIjEgtbrpUTllZ2Fg8yNSAQ9Tb7WamHk1v mxyF+dr+W/zFNiQUCr6znsmoAsyD1kxUsiGWI1mK48xoqTsSHmEsXm1GgR0nfEMt7glS 0IR9l1rIQgjLpuiwAH79LObnmnYIj/a3xSGKpP5n+9JW5Eg4BmOKemBi1ABb8kMslVbx Fw8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=jyPggzZv8VCGivaCuAFS5PLAgo7RpCZi3OBdD1gwUbA=; b=xEb+4xf0RirqLQhJCPFVLpPaP0A95H4BAGEf2KIH7G2xISXRVSgYMnM9oXbdYNSiC+ Sj5c0KTsHrm4asP/Dy5GWzBKkoHJ0MvoVUlciKJ7SR7VRYPWEWAiBK1Xge44ev9SJI8S kPQHfz0m1NtM/cYlStAbPvn+yRGlxOIUcvKL3kmpURDCt8yT+FpAZ0u9sDEGPrPLqW6+ HXipGD9YUAzWAm8Srmst2Duz7hCVPyUQ1PKXog3NRs9A73sqkMOGCdMyGINEK4By4tfx Z6bg9CXhYilfan722aOjblZljMgvzJdT0xebKu33ZlqaMLIt9sMQnqT2H6qf0QH3htFS VYow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=flPVcLwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r6si11380848eds.227.2020.06.16.13.33.44; Tue, 16 Jun 2020 13:34:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=flPVcLwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731774AbgFPU3U (ORCPT + 99 others); Tue, 16 Jun 2020 16:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbgFPU3T (ORCPT ); Tue, 16 Jun 2020 16:29:19 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63343C061573 for ; Tue, 16 Jun 2020 13:29:18 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id e8so4359571ooi.11 for ; Tue, 16 Jun 2020 13:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=jyPggzZv8VCGivaCuAFS5PLAgo7RpCZi3OBdD1gwUbA=; b=flPVcLwI8gnvMfXVRNbVEJqUavqPue+QjklHJXPQpLlK6k++mnVa0GZXHcJIq57gH9 8Jv1exnXrPkmHXNDO8qh1vVMUE0YiW8VNsJMR4y+c0tKlj0FzjLpr960BL0hn/hTMQSb xd00yXAVeExAPGODLd+qBa4yw02HiZII8b/fsGpFOv1EC5BmGJOXsT6DtNAbDy0oF2oR jo2Lj9EU8g0S7OpQ9acAdhyUFkdWYP51XrrEhD1mWCvy/YQUfGEYbhhtwopo8kSIEMuW 5k16rMe3e7/bIwzLG6IHtfFO6WpvVQWZlXK+9TatXRDDd+SmPNyIFgWD/CoGTBzwidgf h82w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=jyPggzZv8VCGivaCuAFS5PLAgo7RpCZi3OBdD1gwUbA=; b=VVmyDs1fKCbBev+A/mM2tO55xExvarZO6ap7VfjCY0QrEUbxZ0bGobPhba/3aa3Obr 4vL3uZTQvsaT3/ku0cxy5/k2vd19BNtiUxXRAJT89btakxZiB4Us1iXcOX6zcw9e8GoT plCH7k80ASOPnSBMW443HeILjImNnCciSD8D6DMXsmEsxWjS+yZ8LOaOXCLinUs+uhpU nyk5v5oG5g5z8cche/jCFClVOvZgbCjoFLHbLxpiTWFnDwFwclv9kqKrqyp4BwW/fBoY +1Xh7djqHkdyz60Se/gDy9Dem8RXIQyl4+/FbgLkGcB69Evn901nGn28v+z4nUTob1w9 rj2w== X-Gm-Message-State: AOAM532PAncuhnFHSVMM4Up8/Q1ItkMbZY00FlWxg3JQbU64JmqGqNL5 SeQYxX9e5X48swNwAWYzHaEc3GbDhe8= X-Received: by 2002:a4a:d1ca:: with SMTP id a10mr3925663oos.31.1592339357430; Tue, 16 Jun 2020 13:29:17 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id k8sm2642811oik.31.2020.06.16.13.29.15 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 16 Jun 2020 13:29:16 -0700 (PDT) Date: Tue, 16 Jun 2020 13:29:14 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Vlastimil Babka cc: akpm@linux-foundation.org, alex.shi@linux.alibaba.com, hughd@google.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() In-Reply-To: <20200616082649.27173-2-vbabka@suse.cz> Message-ID: References: <20200616082649.27173-1-vbabka@suse.cz> <20200616082649.27173-2-vbabka@suse.cz> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Vlastimil Babka Acked-by: Hugh Dickins 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. > --- > 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..8a4e342d7e8f 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 > >