From patchwork Tue Oct 12 18:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12553415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39B17C433F5 for ; Tue, 12 Oct 2021 18:01:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFE9060D07 for ; Tue, 12 Oct 2021 18:01:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DFE9060D07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 914BF940008; Tue, 12 Oct 2021 14:01:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C48A940007; Tue, 12 Oct 2021 14:01:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 764E7940008; Tue, 12 Oct 2021 14:01:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 699DF940007 for ; Tue, 12 Oct 2021 14:01:55 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 09AD039B23 for ; Tue, 12 Oct 2021 18:01:55 +0000 (UTC) X-FDA: 78688553790.19.2DB8F65 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by imf22.hostedemail.com (Postfix) with ESMTP id B085C1907 for ; Tue, 12 Oct 2021 18:01:54 +0000 (UTC) Received: by mail-qk1-f179.google.com with SMTP id z40so18804406qko.7 for ; Tue, 12 Oct 2021 11:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lyh5VszI4R7zeybDzYqsIPSiDXABCH8mlDeTJtPXHYo=; b=uW83OlcYmd9OYcOM7gdtBuDzsXhWtXx1xhFC2d6WrbzMz8avtsJakLyys2WcAwd1id t+puB5jH0LxZZN+VR7IXNhLdGUeCFeEIot2al+WyrrFsMFcrwu/yKJzyNNyFE6+K/rKi 2i8FnA1fOa4exo5V9P4Ilme1WXxoywz7C8xWoWiBw921RNFjH7kfo2PtgutGdCKrBRoY 4pa505He3m0IqeodsA/Z8+ifYbmV6SxZwfNnQ7d3nuryD9A0w2z3+PWk4fe+8BG/B4sA ndwiMUfixeU3DYgvLWGursDymyc5jmBd7KUfoSEpqAOnFOYviOf1xQ3dPZsjVAHQT1JF zuDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lyh5VszI4R7zeybDzYqsIPSiDXABCH8mlDeTJtPXHYo=; b=djZGlYk26VxlYQwxDXd3nsrj7/r/dvyinykuJkkWMtAdWfSme7VZLa8uzlXLVhMSW5 s/7lz4ilbL90jQ7Og06Fr82oNOnM4w3ISrM72C2CTumZGqSeIsWvFRAfUwzGwgmUKnum v98KQtV1e/wlHaENdNVIiZYwqJVRx4bMI0riN/xSZaLTyym9PyLJzTjW2BBy/gH0G2qn dWuOfSqOZRP+ZPUkd1bL+JAmO502qDG2341R5GPBUWZ3MugKD4DIpgDk1V8QF4zH8FpV AdHyxFx3HAAS6yGpijio2QdtIa0JW5S708Ml85w01weLf2MnWXzBA7sF8+eYfRfu2v8y LWuw== X-Gm-Message-State: AOAM531XHRjMI8AI+yYYvMzMQAyNCzc94ww2a5xhEkVmIXT/TvoobqdI 7jAlzXwQc++LYL/YV0uE+A0QVCa2GwP4yg== X-Google-Smtp-Source: ABdhPJzrK8bQDC7NK5HHGHuo4A32b4Tvsk/5CgUECMVqu9ckf3I8IoJVXNxz+cQGMAGQgU4EnksWpA== X-Received: by 2002:a37:2743:: with SMTP id n64mr8926545qkn.394.1634061713973; Tue, 12 Oct 2021 11:01:53 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id a4sm5526589qtm.12.2021.10.12.11.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 11:01:53 -0700 (PDT) From: Johannes Weiner To: linux-mm@kvack.org Cc: Matthew Wilcox , Kent Overstreet , "Kirill A. Shutemov" , Vlastimil Babka , Michal Hocko , Roman Gushchin , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 02/11] PageSlab: eliminate unnecessary compound_head() calls in fs/proc/page Date: Tue, 12 Oct 2021 14:01:39 -0400 Message-Id: <20211012180148.1669685-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211012180148.1669685-1-hannes@cmpxchg.org> References: <20211012180148.1669685-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B085C1907 X-Stat-Signature: 95gzprczz1eos5rn8se8ef7ikmxsmeko Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=uW83OlcY; spf=pass (imf22.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.179 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-HE-Tag: 1634061714-841772 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: Cache multiple lookups in a local variable. Signed-off-by: Johannes Weiner --- fs/proc/page.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 2c249f84e1fd..37d95309e1c1 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -108,6 +108,7 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit) u64 stable_page_flags(struct page *page) { + struct page *head; u64 k; u64 u; @@ -118,6 +119,7 @@ u64 stable_page_flags(struct page *page) if (!page) return 1 << KPF_NOPAGE; + head = compound_head(page); k = page->flags; u = 0; @@ -127,7 +129,7 @@ u64 stable_page_flags(struct page *page) * Note that page->_mapcount is overloaded in SLOB/SLUB/SLQB, so the * simple test in page_mapped() is not enough. */ - if (!PageSlab(compound_head(page)) && page_mapped(page)) + if (!PageSlab(head) && page_mapped(page)) u |= 1 << KPF_MMAP; if (PageAnon(page)) u |= 1 << KPF_ANON; @@ -151,8 +153,6 @@ u64 stable_page_flags(struct page *page) * to make sure a given page is a thp, not a non-huge compound page. */ else if (PageTransCompound(page)) { - struct page *head = compound_head(page); - /* XXX: misses isolated file THPs */ if (PageLRU(head) || PageAnon(head)) u |= 1 << KPF_THP; @@ -185,7 +185,7 @@ u64 stable_page_flags(struct page *page) u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); - if (PageTail(page) && PageSlab(compound_head(page))) + if (PageTail(page) && PageSlab(head)) u |= 1 << KPF_SLAB; u |= kpf_copy_bit(k, KPF_ERROR, PG_error);