Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2274341ybt; Tue, 16 Jun 2020 01:30:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyICNKsUlG71pWFc/sBAJPWA6reKp/0BrUzZZyF4z+clZY8IB86D9Jk8Vm+owrluG4WI+JD X-Received: by 2002:a17:906:7802:: with SMTP id u2mr1759050ejm.478.1592296215604; Tue, 16 Jun 2020 01:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592296215; cv=none; d=google.com; s=arc-20160816; b=uEx/haHw38DFkwuZb15uPaZzzjhjtEz4fawoSZx3gj8ngPAKA8CrCwR/0sGKXapvht Oz9FrPeQLQMAsc0asGFevaVHu5fxYKkJ7jxScviGS+VgaoF1S4Ww2NPzcVmcMbk19obq fqVYv4KJLn9gLEhSc6Akv0LKO0vRSvIHwFLJH8HddALqDsnMMDFl3gh2mKQUKQbBCKHL 0SngnwUNQoDr3xNiulOEGXvq4YAgwb5zdtRG0/X/I6pD3ptrz37wWdhGeWwgso6bGpaJ TJPptHQqC8efGHkXklvGNULrJTm9eQuYynU9wKkc0g+ohI7C1oZx2dStW/8SO8mucjb2 R4bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mj8iaBDpl0JFtAjNuSN7W+hcfT1yH/9cA11GVDDo13k=; b=CG06viHGipYQL0wbp+M9tgjYq6tjeN/0hEjbzAJiM7PjiondDAAQ4cZsjcQehIJNyv QKGX7jcxPNGz/+CTz9gvkTkniE3zXcm2O1Uo5so4dRo6kMCydCO8g0nGMXEBc5ws1E/E Nwukn7764puxlXn675Rd4mOG2Kt9YZgei/i50tUgQaOl7BoVrc8qebHS7FhWE9FF7hoN jjl9DerCT8hqiJGvE+s40waelltmXra40rbtU4NuPXUyHCw3rYEKSQqYMiveIahMxizF ncwa1nme1dUDa24ISy9ruNQRzS8WLbWHIuSpHtlcpZJ8L009yozNKu/x+JVdxLV5bpXJ 1wsg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck26si9696587edb.166.2020.06.16.01.29.53; Tue, 16 Jun 2020 01:30:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727962AbgFPI1N (ORCPT + 99 others); Tue, 16 Jun 2020 04:27:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:49358 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbgFPI1N (ORCPT ); Tue, 16 Jun 2020 04:27:13 -0400 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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