From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF563C433DF for ; Tue, 16 Jun 2020 20:29:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 662C72078D for ; Tue, 16 Jun 2020 20:29:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="flPVcLwI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 662C72078D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E25B46B0007; Tue, 16 Jun 2020 16:29:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD6A06B000A; Tue, 16 Jun 2020 16:29:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9E2C6B000C; Tue, 16 Jun 2020 16:29:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id B07136B0007 for ; Tue, 16 Jun 2020 16:29:19 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1B9F5180AD807 for ; Tue, 16 Jun 2020 20:29:19 +0000 (UTC) X-FDA: 76936214838.27.join48_1f0113e26e01 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id D77663D66B for ; Tue, 16 Jun 2020 20:29:18 +0000 (UTC) X-HE-Tag: join48_1f0113e26e01 X-Filterd-Recvd-Size: 4939 Received: from mail-oo1-f67.google.com (mail-oo1-f67.google.com [209.85.161.67]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Jun 2020 20:29:18 +0000 (UTC) Received: by mail-oo1-f67.google.com with SMTP id q188so4358148ooq.4 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=MiT2SntwUbioH2PROb6V85qnu4ww5q/HFjBPay0CrrLALooEDfOvvUeA5VjFuTJ19F OEFjRSjmeR3TEsAjP74EuFo7LjubUWvsZsanWpZPFRPKhkAYEHtmqsGx2HuipEQcWuxK p2DDNAupOWCf+IQ/KzaMjxbH29N/lg4223j44pCeHcSu7N7F+zd1nxfuU34LUt8FmrLL ZqffOhy8XF3oksQaP8YY8yEaF7idyKze8M5HfpM9dSvMZXSCZZXlKoQ3mnBsk+JKTGIX Pw1NL6A9txb7nrNtmtTKczZ+RwJfrgBb2sbS1R+UUrNB8ZTP8G7p/95DPaIHBo34o/uU h+ww== X-Gm-Message-State: AOAM530xSl94B3jUwZBGf/NeW+XhrSU9thYRHW1uBMe2Fc9ZL+CUp4HG aOWILowF81zdT/wS9OAu8fTVLg== X-Google-Smtp-Source: ABdhPJzMYPbcuFOwOPomE3YNa4+25hJDx36Tn/T4Kmez4WBptaadokkxnblUUtOAc4F982FOWYusYg== 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 X-Rspamd-Queue-Id: D77663D66B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000125, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 > >