From patchwork Wed Jul 17 01:16:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13735019 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1017C3DA49 for ; Wed, 17 Jul 2024 01:16:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E7616B008C; Tue, 16 Jul 2024 21:16:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 321D06B0092; Tue, 16 Jul 2024 21:16:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19B816B0095; Tue, 16 Jul 2024 21:16:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id ED8DC6B008C for ; Tue, 16 Jul 2024 21:16:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 938CD1A07C3 for ; Wed, 17 Jul 2024 01:16:39 +0000 (UTC) X-FDA: 82347479718.30.990233A Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf21.hostedemail.com (Postfix) with ESMTP id CD4AA1C000E for ; Wed, 17 Jul 2024 01:16:37 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1RlOJKFR; spf=pass (imf21.hostedemail.com: domain of 3dBuXZgYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3dBuXZgYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721178979; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WYs2NQlUzYrTkY7/jBEocDDb/Fk2gTcTv8X97Q6ft2U=; b=cTIvPXptlx8JA8ZhNK6Hq+3EH8VVn4yQU9m6b1CDUOlLLuetECNhtv/4jvGn1SotNwDRPy 5JhCbD3nFcnrLyFHQBjhjqBWt3mhfHJhvAfcz60Gfv85Amyr3HcJ6Lzj0PIM4sqZdXf9dR 5HhT6YsphrXvDSyin4uAMYFrSb3CQYE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1RlOJKFR; spf=pass (imf21.hostedemail.com: domain of 3dBuXZgYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3dBuXZgYKCEMxzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721178979; a=rsa-sha256; cv=none; b=DKYznl2NjHPEgh/HC7JMsS+aNpuQgcLx2ZTcboMZO3xEI2rrSALQ/Cr4KtHzifUvarOqnN FaJv1Ghtl6Po+oB+rPl3GPUoScgrGZtM/7w18yf1CDEbPp86RgFz3K90moVWpykM+mtbU4 7gGbEdb0ZCz4IpT/uy0scytWwI1NsMg= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65e7c42f28dso123232327b3.2 for ; Tue, 16 Jul 2024 18:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721178997; x=1721783797; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WYs2NQlUzYrTkY7/jBEocDDb/Fk2gTcTv8X97Q6ft2U=; b=1RlOJKFRXLEDH6DP2KWU92pd9YTMtEVbFWypR4zAaEM+PCTmSr9Ipu8VVoeu83ezKO 6/QKqbYPj6CJGOE33fInEmav+1bhZSoDFQc7g0uFvAgANAONmxOW6qFJwlVCxernRIOx 2KJ4JSm6A0sB2ceoIpngz0ebPbhlFt2d3kkOPlmS4iXihZxN/A41QkStyBXR38lJtYe0 dkE8l9/T13iFC7xF9KcvueGhRfkZOJiQUQY53lKYTxtZS58otK08V1o5xZ+81lX//nvJ 2w5IAKZZ5hiXZQFgWFtB7mq+3aOf8iRPRLfXaylmvzQTUiR0pUhGdgSsRZfG2y++dj0G zUeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721178997; x=1721783797; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WYs2NQlUzYrTkY7/jBEocDDb/Fk2gTcTv8X97Q6ft2U=; b=AmnXElIrOzoakhPu63N7quERKvoMD7h9ROKLRyQEKIxXo/4pbX1UmOVtIoKaTN+uu0 rPLjukkXaMpGg1BhtWqmOVMiR1JMOiMYD/TqEpXWoh/fBZEeDI1lQPiFAFnhZ7ywJZyp 7C8OOfzzmcVITM0VkHCo5k3038Q6XjnEw2tOGRPtoM6L/+nMa8+2pax0Kxi7GbaEPpVK NSL64MBPNR7VCkKMnSp5au6cGGagrpCi8PS8ToilPa0X1axtYKuiAH4sxHKZrQc2S6/Z zr1Vl3HhRMaetC2BxHAVLPbPgXX9oKymJse4wTxDfpgU1l/fe+Mhmiu9grfbuZG9yOzE TLZQ== X-Forwarded-Encrypted: i=1; AJvYcCWNj1IlvQ0UcCBV2CrODncdMZhsFmBdqJncfSAj5VUhakIsPoOUGA8d8+YM/b6l4Tab9uP0BuPoE7awnSGQK9oGBBs= X-Gm-Message-State: AOJu0YzEoUScL/dEtjekUJKa+DBRWB1rA17Cys285qJ2tVnEZPAEuKWf VaEmEWExlz+k0/9u6nnF4VLmYG2oRguTn4L255xvul2Am1r6iuW3WRYLe0DvAyfzQ/ucdhRU+cf /Sg== X-Google-Smtp-Source: AGHT+IG4pSDPzKKXsAL5A6p3APpsyei6VOH/oQKykr78n8RykTCZ1xTwjZZ801/bXu/vlGnVQoRe9PYRGjg= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:9b4f:4efc:3f93:ed78]) (user=surenb job=sendgmr) by 2002:a05:690c:19:b0:62f:22cd:7082 with SMTP id 00721157ae682-664ff8d9a69mr152627b3.5.1721178996997; Tue, 16 Jul 2024 18:16:36 -0700 (PDT) Date: Tue, 16 Jul 2024 18:16:30 -0700 In-Reply-To: <20240717011631.2150066-1-surenb@google.com> Mime-Version: 1.0 References: <20240717011631.2150066-1-surenb@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Message-ID: <20240717011631.2150066-2-surenb@google.com> Subject: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, hch@infradead.org, vbabka@suse.cz, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, surenb@google.com, kernel test robot X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CD4AA1C000E X-Stat-Signature: 1dys36i91inh8uywuic6hjh35cqo334b X-HE-Tag: 1721178997-315695 X-HE-Meta: U2FsdGVkX19pWnrAJi1ahd5+5mryFddi/l8zuw0U8y9pucCFoKHG2M4sW1yQqjuhJnE3vqWmZfNydOnHYUEKIf6PU3CrT0gEjbnX0TI49ToHXdmfOIiEmcxQkTFDeXGL9uB/ugL/G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NqyCrJCn5UMbp9bf6Vi+lme4hxVgA6QKDktMqnr+56IMrvp1X/0UlxZSNvSxLpozx0hJ6i56O//vaYqFN07+NIzJ89oxZRYj3EIN8I+lmCMO5ABQmlSr0GfJ3o9fCgvFexIZ++Z7SwBMTAnkAr7AHJKjSTKDtrtqFLEA3pZg3ko3fL0zJ5Lnwc1pFrXlVt/AbGc7XMgApQpDXJXkTqvJg1sn8SyXVcn/kRDG9a0kgZ6JWIQQTeJEAvZjy5KvLMbm+hqSOD/bQSqI/Rl6XlmTDmn0n6A6uW2Eph2paieajkttUTH7yWUblO6KpDppX6XvKn1ZUyNLt6gFuuFG5fsumTQ37VJKEre3mlyRJa2OMOtuNfH1K0mPgAS6ATF/stY8d+LfVt5tv9n/aVkeqkQ60nSMrv1AQPpVIEzQ3MtdhSEVNc/KcQRzmIRvl41o5BE9ZZuHzT6TivFOpgymyo1hhuQzFBUGOgh2dWJrAA2qc2+9w= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Outline and export get_page_tag_ref() and put_page_tag_ref() so that modules can use them without exporting page_ext_get() and page_ext_put(). Fixes: dcfe378c81f7 ("lib: introduce support for page allocation tagging") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-lkp@intel.com/ Suggested-by: Christoph Hellwig Signed-off-by: Suren Baghdasaryan Reviewed-by: Christoph Hellwig --- include/linux/pgalloc_tag.h | 23 +++-------------------- lib/alloc_tag.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h index 9cacadbd61f8..3c6ab717bd57 100644 --- a/include/linux/pgalloc_tag.h +++ b/include/linux/pgalloc_tag.h @@ -13,6 +13,9 @@ extern struct page_ext_operations page_alloc_tagging_ops; +union codetag_ref *get_page_tag_ref(struct page *page); +void put_page_tag_ref(union codetag_ref *ref); + static inline union codetag_ref *codetag_ref_from_page_ext(struct page_ext *page_ext) { return (void *)page_ext + page_alloc_tagging_ops.offset; @@ -23,26 +26,6 @@ static inline struct page_ext *page_ext_from_codetag_ref(union codetag_ref *ref) return (void *)ref - page_alloc_tagging_ops.offset; } -/* Should be called only if mem_alloc_profiling_enabled() */ -static inline union codetag_ref *get_page_tag_ref(struct page *page) -{ - if (page) { - struct page_ext *page_ext = page_ext_get(page); - - if (page_ext) - return codetag_ref_from_page_ext(page_ext); - } - return NULL; -} - -static inline void put_page_tag_ref(union codetag_ref *ref) -{ - if (WARN_ON(!ref)) - return; - - page_ext_put(page_ext_from_codetag_ref(ref)); -} - static inline void pgalloc_tag_add(struct page *page, struct task_struct *task, unsigned int nr) { diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 832f79a32b3e..5271cc070901 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,28 @@ struct allocinfo_private { bool print_header; }; +/* Should be called only if mem_alloc_profiling_enabled() */ +union codetag_ref *get_page_tag_ref(struct page *page) +{ + if (page) { + struct page_ext *page_ext = page_ext_get(page); + + if (page_ext) + return codetag_ref_from_page_ext(page_ext); + } + return NULL; +} +EXPORT_SYMBOL_GPL(get_page_tag_ref); + +void put_page_tag_ref(union codetag_ref *ref) +{ + if (WARN_ON(!ref)) + return; + + page_ext_put(page_ext_from_codetag_ref(ref)); +} +EXPORT_SYMBOL_GPL(put_page_tag_ref); + static void *allocinfo_start(struct seq_file *m, loff_t *pos) { struct allocinfo_private *priv;