Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp361389ybt; Wed, 17 Jun 2020 02:57:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRacMqTcg+uFF9hUztr5RrIU0ZFjT8Kpx2H50C5cuJrucTD33gD03hSh6ucQHs4pghD5yj X-Received: by 2002:a17:906:2bd8:: with SMTP id n24mr7197194ejg.83.1592387850465; Wed, 17 Jun 2020 02:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592387850; cv=none; d=google.com; s=arc-20160816; b=v2RJBJ6wXCsItgPFyXFjJ5EN5J6v7lKmvdhiGEPNX4SD5RgZXtgW3yesRtRuijbHuM xR/Z5XF880wFN6ePFPtZAnvIUocAqbPIkxsTJr6JZcdD+qOjYu/kfzhT2ACjnaVXx4/a 45XzcZE7VJtMk6Jggzb9zAeX4xiNfOA04L5/ITL9tdy1qh5rvIWgSE0BhrBx50MeimWs wju4sce8LTN6rBDIMY8WRDPQQkeNKcNxwAN6wTEq03gumpA/sVxjiZu5qzDDsR4eB55l RGXIwYx2C9Dnx1MalZGNmKmRvqiBiDBPM5iLDpOzGlrrJa2tWc7hKR3eewIjwg9hDlUe 0X8Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=bIJ1owyjT+VRg2o8uIjyXhvkA99OJXWHJNrMc33HIxo=; b=vAnlKn7yajaxf7n0vDnpkYHR+eSOrhBn15fYAIcycZ9FlnNl0tUB2/BiaeRP/Bssnq AuGrsX4u4KmQhTG9eB3a4LA8cOdzoeWlEnTRSj4PmUgY42v0sOuduteLV3LVkOL/K+Yt I3GKtKKEzDm803+lZpdLleOlVw9yNX9zQvpXHSwV7gzAIw2l2siGBa072IrPLrYUBw0k lUD0V4gnlh9vIn4hMG/VPWhK6650bmBxbav25W/+rk83eh7fnwQEVBf3i5nvs71ke4QU qh17D1r8NMMP4ZkLumCLnAO1blz657DVyfOMGbUG9PcW2g3jhlHCoquojn0Dh3rWCt3Z Zi4Q== 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 v9si11021429edr.417.2020.06.17.02.57.08; Wed, 17 Jun 2020 02:57:30 -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 S1726542AbgFQJzL (ORCPT + 99 others); Wed, 17 Jun 2020 05:55:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:48066 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgFQJzK (ORCPT ); Wed, 17 Jun 2020 05:55:10 -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 DD7C2AC50; Wed, 17 Jun 2020 09:55:12 +0000 (UTC) Subject: Re: [PATCH 2/2] mm, page_alloc: use unlikely() in task_capc() To: Hugh Dickins 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 References: <20200616082649.27173-1-vbabka@suse.cz> <20200616082649.27173-2-vbabka@suse.cz> From: Vlastimil Babka Message-ID: <4a24f7af-3aa5-6e80-4ae6-8f253b562039@suse.cz> Date: Wed, 17 Jun 2020 11:55:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> Signed-off-by: Vlastimil Babka > > Acked-by: Hugh Dickins 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 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 Signed-off-by: Vlastimil Babka Acked-by: Hugh Dickins --- 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