From patchwork Tue Oct 12 18:01:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12553433 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 F28ACC433F5 for ; Tue, 12 Oct 2021 18:02:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A84F1610CC for ; Tue, 12 Oct 2021 18:02:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A84F1610CC 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 0890B940011; Tue, 12 Oct 2021 14:02:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0394A940007; Tue, 12 Oct 2021 14:02:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF715940011; Tue, 12 Oct 2021 14:02:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id CF203940007 for ; Tue, 12 Oct 2021 14:02:03 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 604CD2D011 for ; Tue, 12 Oct 2021 18:02:03 +0000 (UTC) X-FDA: 78688554126.03.D53D175 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by imf10.hostedemail.com (Postfix) with ESMTP id E9E5F6001987 for ; Tue, 12 Oct 2021 18:02:02 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id g14so227407qvb.0 for ; Tue, 12 Oct 2021 11:02:02 -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=a7XABMOoymgkbcoo6ZtkRDMSDt06eIQo5rFsIuxFmeE=; b=m5wmVkJMh33Z9cOp79n7VVYuLnyUoX7yOoJUKNLNg4xJqPTZj4Ia1mLGb5Pf3vbkuM pcJuVSqiwxXq8xiJ7jvfyne8fnCj8hcS+7/9/9bHPWhYmHEayMlxPoGFfZiS62GKc7Bp OOJaJFO8wiOtXuh1Rya0oeNfC7gU3WJsxLCurYqX4grXeqdgpQ9lgMAwFAr8bsZH+Okb aLdPzVMPy+EpA5O1YbEyKYPt/x/gZeEzrUUpt8Oei07UKQg4U1f3hptZBPlNQicpqcXP L2T6ja/boBEdOcQaonHA2XU3k5LoU/VmQFuk+45B/qAY4Pr4ymC1gpMBvLutTiGZdgfU xrbw== 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=a7XABMOoymgkbcoo6ZtkRDMSDt06eIQo5rFsIuxFmeE=; b=NIy5QJHmcG2ynE2DB+XRbC2vtIP6zpga1xqfBA7ZeMhOxDIEep4yU1K+A3YGIMW1qZ tH9ZsiBuRuuprQoSDzjFO7cHoDZ07EwSg12HqyTfmM5dkisnWJrtGWd5FBQKq89Jj64o kEyTbBJBBtsdsqRyR9IdPgUA7UpLLgmJJalJ3WraCLCqlOCY8yczKj+R8ocrfBU7SobY ySVigxa4AjQJJzdACt5+zFQVf/3t+W7Oy3jPSIicbVloMogngn3rw3r+vlTF07gqjPqM et9b7U9OlAq3j7vs6NPOnh+9CxeEw60pt5ZwfprJMjWxkgrS3zhO3vZErnnVy7L6knJ/ QRqA== X-Gm-Message-State: AOAM53110p5ltCh1sDPrbdvU1oS0U4pB0gJ0KiYOQ7y6JN91AY2qbFSO DPTneBV5xHeCLmIVsfsO4nM52Da0OskyZg== X-Google-Smtp-Source: ABdhPJwl5SDEbPaff1ENR4HVvlY5tr2GgtyFZjAxERPqQ4NzNIGb7/CniB5M5sALLSfvwuMi6AoxSw== X-Received: by 2002:ad4:54c8:: with SMTP id j8mr31830935qvx.45.1634061722202; Tue, 12 Oct 2021 11:02:02 -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 b20sm7191158qtx.89.2021.10.12.11.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 11:02:02 -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 11/11] PageSlab: eliminate unnecessary compound_head() calls in mm/memcontrol Date: Tue, 12 Oct 2021 14:01:48 -0400 Message-Id: <20211012180148.1669685-12-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: E9E5F6001987 X-Stat-Signature: iwmsgt8bptdddg6t8g93yaysnw1go8dm Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=m5wmVkJM; spf=pass (imf10.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.54 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-HE-Tag: 1634061722-168652 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: page->memcg_data is generally not valid on tailpages, so the accessor functions don't need to worry about encountering them outside of bugs. The only place where the memory controller may encounter tail pages is in mem_cgroup_from_obj(), but that uses virt_to_head_page() first thing to resolve slab objects to slab pages. Signed-off-by: Johannes Weiner --- include/linux/memcontrol.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 02394f802698..3096c9a0ee01 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -397,7 +397,7 @@ static inline struct mem_cgroup *__page_memcg(struct page *page) { unsigned long memcg_data = page->memcg_data; - VM_BUG_ON_PAGE(PageSlab(compound_head(page)), page); + VM_BUG_ON_PAGE(PageSlab(page), page); VM_BUG_ON_PAGE(memcg_data & MEMCG_DATA_OBJCGS, page); VM_BUG_ON_PAGE(memcg_data & MEMCG_DATA_KMEM, page); @@ -418,7 +418,7 @@ static inline struct obj_cgroup *__page_objcg(struct page *page) { unsigned long memcg_data = page->memcg_data; - VM_BUG_ON_PAGE(PageSlab(compound_head(page)), page); + VM_BUG_ON_PAGE(PageSlab(page), page); VM_BUG_ON_PAGE(memcg_data & MEMCG_DATA_OBJCGS, page); VM_BUG_ON_PAGE(!(memcg_data & MEMCG_DATA_KMEM), page); @@ -466,7 +466,7 @@ static inline struct mem_cgroup *page_memcg_rcu(struct page *page) { unsigned long memcg_data = READ_ONCE(page->memcg_data); - VM_BUG_ON_PAGE(PageSlab(compound_head(page)), page); + VM_BUG_ON_PAGE(PageSlab(page), page); WARN_ON_ONCE(!rcu_read_lock_held()); if (memcg_data & MEMCG_DATA_KMEM) {