From patchwork Tue Oct 12 18:01:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12553411 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 117E0C433EF for ; Tue, 12 Oct 2021 18:01:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7DF4661050 for ; Tue, 12 Oct 2021 18:01:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7DF4661050 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 0D76E900003; Tue, 12 Oct 2021 14:01:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08719900002; Tue, 12 Oct 2021 14:01:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB91B900003; Tue, 12 Oct 2021 14:01:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id DD2EB900002 for ; Tue, 12 Oct 2021 14:01:53 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7F0DD2C5A5 for ; Tue, 12 Oct 2021 18:01:53 +0000 (UTC) X-FDA: 78688553706.23.E516FB6 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by imf10.hostedemail.com (Postfix) with ESMTP id DE0BE6001999 for ; Tue, 12 Oct 2021 18:01:52 +0000 (UTC) Received: by mail-qt1-f177.google.com with SMTP id y11so112931qtn.13 for ; Tue, 12 Oct 2021 11:01:52 -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:mime-version :content-transfer-encoding; bh=jZVSq/QQ0LXyDCUs082Ufi1LJb8/1UawzHS4L/yAETI=; b=dTMXcs5ow1uGJIpzZktTFZfgi8P1mJWd65Ng6Pebv9FLS3ypgK1E6U6QX8KVrlk/3w 6TbO8rschFzjfwrFJevf4xKdKOoAC6GJe3B+y1P++T8qOenyljLW27+8Qll1LDL5avST 3OqPIiFYVQYWMDjVMWuZRtUSw54vyOBHIO+yatqbw8VT1Si0tLZ/i1TXfdtRUR/s29cD hfz0WmFGxL2AydwQCbw4aRsLyEDfjquTTuJvqBRzm4w0Kd+O38osTuXgMu5Vg9yPadk6 VvdhJ6LnnDnZsTOR3WHWJ6HBimlWOHVYRtgRKEXH47bI2QcMxrg/A3GEjSr9DSm7dVd4 bAlQ== 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:mime-version :content-transfer-encoding; bh=jZVSq/QQ0LXyDCUs082Ufi1LJb8/1UawzHS4L/yAETI=; b=BJbK8Nf+V9aR1O1LmByDQSfx62SS48tPLiI5bVuYSuNyrajG8LYTV1pwy0B3s+FpJW J6DT0jvcIx2upOjs0N93kISHc+JJP6fadLJE4+P9Z17e7Z8MZ+1vUfd4wV2WKra9d4qi iQ3g3/8vju/s42Ly5wTyWsalrmAWOx0O8ZtU2KHZ88XYHMSxwqLYzy1ZXfJ9JlkmlxX2 ALGNdhMUbGBPeqJOAtI/OV2i81pGfrVYnk23UXs24osrqufhYcpOyk+vCujw/yRo/5S0 iE+hDU4Mi7JbgrrB+aYtEIvyJltyqGWb7dcW2VjzGelKhO1rXwytl+q5yv1+Q4YJLKG6 UWDA== X-Gm-Message-State: AOAM5338OQKVN8N9imBlLumlVSRabSp4IBwZRV9D932WhdK15pKAvFcX 5I/Ho1YW5qzmFX9hroAQ6uZtNM7Sd8DXkw== X-Google-Smtp-Source: ABdhPJyAIgYpX/YkGKVVwQ2kvAOZ8RaSQxwhyfOToQYuWzTo05dgoCDs3JCrJeUHRVM7TzV917UpcQ== X-Received: by 2002:ac8:7059:: with SMTP id y25mr23387455qtm.404.1634061711972; Tue, 12 Oct 2021 11:01:51 -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 q27sm2449377qki.57.2021.10.12.11.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 11:01:51 -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 00/11] PageSlab: eliminate unnecessary compound_head() calls Date: Tue, 12 Oct 2021 14:01:37 -0400 Message-Id: <20211012180148.1669685-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=dTMXcs5o; spf=pass (imf10.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.177 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DE0BE6001999 X-Stat-Signature: k1odfi38caj4ym38ombzy1167nu7ji9a X-HE-Tag: 1634061712-769534 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: PageSlab() currently imposes a compound_head() call on all callsites even though only very few situations encounter tailpages. This short series bubbles tailpage resolution up to the few sites that need it, and eliminates it everywhere else. This is a stand-alone improvement. However, it's inspired by Willy's patches to split struct slab from struct page. Those patches currently resolve a slab object pointer to its struct slab as follows: slab = virt_to_slab(p); /* tailpage resolution */ if (slab_test_cache(slab)) { /* slab or page alloc bypass? */ do_slab_stuff(slab); } else { page = (struct page *)slab; do_page_stuff(page); } which makes struct slab an ambiguous type that needs to self-identify with the slab_test_cache() test (which in turn relies on PG_slab in the flags field shared between page and slab). It would be preferable to do: page = virt_to_head_page(p); /* tailpage resolution */ if (PageSlab(page)) { /* slab or page alloc bypass? */ slab = page_slab(page); do_slab_stuff(slab); } else { do_page_stuff(page); } and leave the ambiguity and the need to self-identify with struct page, so that struct slab is a strong and unambiguous type, and a non-NULL struct slab encountered in the wild is always a valid object without the need to check another dedicated flag for validity first. However, because PageSlab() currently implies tailpage resolution, writing the virt->slab lookup in the preferred way would add yet more unnecessary compound_head() call to the hottest MM paths. The page flag helpers should eventually all be weaned off of those compound_head() calls for their unnecessary overhead alone. But this one in particular is now getting in the way of writing code in the preferred manner, and bleeding page ambiguity into the new types that are supposed to eliminate specifically that. It's ripe for a cleanup. Based on v5.15-rc4. arch/ia64/kernel/mca_drv.c | 2 +- drivers/ata/libata-sff.c | 2 +- fs/proc/page.c | 12 +++++++----- include/linux/net.h | 2 +- include/linux/page-flags.h | 10 +++++----- mm/kasan/generic.c | 2 +- mm/kasan/kasan.h | 2 +- mm/kasan/report.c | 4 ++-- mm/kasan/report_tags.c | 2 +- mm/memory-failure.c | 6 +++--- mm/memory.c | 3 ++- mm/slab.h | 2 +- mm/slob.c | 4 ++-- mm/slub.c | 6 +++--- mm/util.c | 2 +- 15 files changed, 32 insertions(+), 29 deletions(-)