Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2671734pxb; Tue, 12 Oct 2021 11:03:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYdvBeIgDZ+fVKmEbTqAlfriDRa7nu6LUm9Gpzw3wAZ/5kh+Y510pGIlPwBW8bF7e3gwaa X-Received: by 2002:a63:b707:: with SMTP id t7mr23681689pgf.55.1634061815230; Tue, 12 Oct 2021 11:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634061815; cv=none; d=google.com; s=arc-20160816; b=onqXqrPr0qBtRIWYw2xiDP0t9o5d0n85OQk01KNSkrA9Ljs5E1fBoVoDK6n/GaMO94 PU2r5P4EpVPSNRpoUJMJRBOQXdBs0J+UnfAxjCEE7Ew2JgQGxYL4vHDae7S+eiEqVmtB Jgu48BHUNnth5y23fU9Hi/GJlMi44+VDO6UBBfDMWyqAbInxUFdcNwH/Nf28kWQ/JTv8 mzsmrvms47zZ5oVublYOLE2B/Y4FgEpIRM2eW+dPMvtVt+GCyGPXwcc3vqZrJVocO5ZQ T2dnAI55lMlPJ5hJTQt0uQEpHITp05ls5bO4myAYjhVtAydLyRWtsIH0Hj531FnkifKn 1emg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jZVSq/QQ0LXyDCUs082Ufi1LJb8/1UawzHS4L/yAETI=; b=Sykgu9N9Jv2J+Gjjp7ZYyv1CqtJhnPm2UR0vpf3JX+2h5oZ+Xw4UYA4HKVaW6FyK// OQ5g/lglYqWmENVMY1Mtz0gQ3aI3kWqgYLxonXwDqxdeqgBhUx5cnQZ28zxTNGwjjxh9 giB55LKYG4+lQ7ll7PGRkv2D6JhI6xDq3zJXaCeSKH0KScsiWpstYsb0e7r07Rengpi/ Gfx7/yzwRjqY1Jna2hzMcbGlcwrc0BvDkZrOqIGKb42bPBc9vsUCfNhCpFeb1QZ8nFTs C48wvlRyNkFJBnG2TpBo0ufPM+dG9tJD9Wf07LVQVwXOHuVttUdlquP/lxvdCbAAz+FD GU5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=dTMXcs5o; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oj15si5771872pjb.125.2021.10.12.11.03.15; Tue, 12 Oct 2021 11:03:35 -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; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=dTMXcs5o; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230002AbhJLSDz (ORCPT + 99 others); Tue, 12 Oct 2021 14:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbhJLSDy (ORCPT ); Tue, 12 Oct 2021 14:03:54 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0B8DC061570 for ; Tue, 12 Oct 2021 11:01:52 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id c28so124007qtv.11 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=wVJKDMLCee8K7eQhjq4jZLO8zDRu1gqSwI2y6JBiR8P+ZRWvjSc7vyO3l55L+12mef /kZKTtiUfD1bzCUvReknrqlnceq0VUffV7phJ21QahiMQYdHfFohDHR+9Q3L3rZP5CpV nGoVMzhlmDPUfmMyXd92hxM2KanCAT9e4PGt3uswFZzavKNvZpS9Ed/tUUMz+EQMjmkJ j/a5azHe1Rt85VsvcjV2YbQakbeXaAjyI2NVrXIa4EIwhbrV3NJY+//ModOAofgVu+XY XHWUD0PFaW3IiolDXSjfCa/Stp33iZVQc6VmHuvt1sNH+ASvcjUMAENCa6vCN/ESgZQv 0GMw== X-Gm-Message-State: AOAM532lxOK/19oV/Ol2qtOD348eHQIuzVh/5XM0111PfBkNHG6Vcbfs DPm/xWlt8u6/S1Ib/KQyYU54oA== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-)