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=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 5A447C433E3 for ; Tue, 16 Jun 2020 08:27:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 26D7B20739 for ; Tue, 16 Jun 2020 08:27:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26D7B20739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C9E538D0001; Tue, 16 Jun 2020 04:27:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C57546B007E; Tue, 16 Jun 2020 04:27:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACA3B8D0001; Tue, 16 Jun 2020 04:27:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id 8AF326B0080 for ; Tue, 16 Jun 2020 04:27:13 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 51A7B1EF1 for ; Tue, 16 Jun 2020 08:27:13 +0000 (UTC) X-FDA: 76934395146.04.bun90_1804f0126dfd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 2A5FC8001B12 for ; Tue, 16 Jun 2020 08:27:13 +0000 (UTC) X-HE-Tag: bun90_1804f0126dfd X-Filterd-Recvd-Size: 2245 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Jun 2020 08:27:12 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1F720AE2B; Tue, 16 Jun 2020 08:27:15 +0000 (UTC) From: Vlastimil Babka To: vbabka@suse.cz 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: [PATCH 2/2] mm, page_alloc: use unlikely() in task_capc() Date: Tue, 16 Jun 2020 10:26:49 +0200 Message-Id: <20200616082649.27173-2-vbabka@suse.cz> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616082649.27173-1-vbabka@suse.cz> References: <20200616082649.27173-1-vbabka@suse.cz> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2A5FC8001B12 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hugh noted that task_capc() could use unlikely(), as most of the time the= re 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 als= o always sets cc->direct_compaction true. Suggested-by: Hugh Dickins Signed-off-by: Vlastimil Babka --- 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(str= uct zone *zone) { struct capture_control *capc =3D current->capture_control; =20 - return capc && + return unlikely(capc && !(current->flags & PF_KTHREAD) && !capc->page && - capc->cc->zone =3D=3D zone && - capc->cc->direct_compaction ? capc : NULL; + capc->cc->zone =3D=3D zone) ? capc : NULL; } =20 static inline bool --=20 2.27.0