From patchwork Thu Jul 11 22:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13731118 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 C44FFC3DA4D for ; Thu, 11 Jul 2024 22:05:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25D5F6B0098; Thu, 11 Jul 2024 18:05:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 20D306B0099; Thu, 11 Jul 2024 18:05:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05FE56B009A; Thu, 11 Jul 2024 18:05:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D40A36B0098 for ; Thu, 11 Jul 2024 18:05:07 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9041A16082D for ; Thu, 11 Jul 2024 22:05:07 +0000 (UTC) X-FDA: 82328853054.28.FE39911 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf22.hostedemail.com (Postfix) with ESMTP id CB2F6C0021 for ; Thu, 11 Jul 2024 22:05:05 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Mi312nNO; spf=pass (imf22.hostedemail.com: domain of 3EFeQZgYKCDsprobkYdlldib.Zljifkru-jjhsXZh.lod@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3EFeQZgYKCDsprobkYdlldib.Zljifkru-jjhsXZh.lod@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=1720735479; 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=XUqZ9LjRSmNrW6ngPL3y0CGgomBIu4HcNtQ8V/Usrc4=; b=w5XixM7Pn4HTWdLMfAtOKxKKedIXm+GmrIoZgT8E9/pco1KfzCpu7npZJDxqxUalH5+CHC Pa7Y2L2+tqMGej1R1CZIGHE8J45QQ64W3sewrv3pKb28xAXRDqyqScwa28D3Z1ONxL6OZk tkkZcnWcJekN/KROqlUw2tQYWozC3hg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Mi312nNO; spf=pass (imf22.hostedemail.com: domain of 3EFeQZgYKCDsprobkYdlldib.Zljifkru-jjhsXZh.lod@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3EFeQZgYKCDsprobkYdlldib.Zljifkru-jjhsXZh.lod@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720735479; a=rsa-sha256; cv=none; b=kcX0+hFoHV2j0Ct/rL6Vryom5wvkROucUaU0osJEF0EYu4vVBQ7Y69ZrHFnt4472YVTFSW 1TfCIPSihCWS/W5JQ88kYLLjQa6W/DYfL2CZY4bP1JD8ucnBJCuy9Txn1A9TKQyvwqWOTj Qp8ztIzpp+zLU6KGyGXOuttIm8/7O8U= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dfa73db88dcso2527521276.0 for ; Thu, 11 Jul 2024 15:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720735505; x=1721340305; 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=XUqZ9LjRSmNrW6ngPL3y0CGgomBIu4HcNtQ8V/Usrc4=; b=Mi312nNOlJ+3cYMR/yHBIwDy9a7fKrNBUUI3P5x9LFCfRgqAJ4y2ybTDm6g78kstXW U/qyDaP0bMqWvqDgb9+0PRkNfZAtp3LKhZ/WhDkF+GykEGKsfNQ0AZw4tr8/KyeXIwVj wJM4eCHfxXqkqoQzIR+4e0CpYLglWNTzNJukYzvtTif9unjpTwpEBrt5oUqzpzspVMrW xBAPvnx/5p8he8UL8UOILwKSGGSzGsTxkI3W5Ul/euOCsjVd3BP5bsmqyPrS2hT/x/Wn iV/8MIP0gWpLubFWusuaq/4jbMmxUa9TTM5bZjpP85ih2U5/JWyUnW4kI7gju8ruhbSC boQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720735505; x=1721340305; 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=XUqZ9LjRSmNrW6ngPL3y0CGgomBIu4HcNtQ8V/Usrc4=; b=RfJKG2K8wRbQTEeI6W6F/c4tp2Tu/yTOrJ751msSJ/CkgmG319pC6e750NaTPK0EmR MVuaiPKN09mAB96Aa9SW39aqgfGjpvNiTJ1SZQnV86w9qNGRTufU21OrCbbnYEcwPWOI KAzyQtREV6JRWi/g1ol+XyA7wHq7Ig0Raeuz3Es9Wcd8VQgq9JTievQrDCW9HpcPBCBG GtrIvuEDqmMto+JAuK7owlX4/FfnoBV+j4wVzBdnToVaW5GsRTpnJ2oisq5EwYUZfeIo X0fR0ZVDxyqMs8us0tAZ3Lb4AU7FPYSqnlV3FIgRv8MA5PxFnrUbN6XDd44DiUZyzTeP 038A== X-Forwarded-Encrypted: i=1; AJvYcCV/AcHFba032PYrmhR4tiQdyJUkC/Y80MXUv/URiO7TRMPGw6mcU5y9L4aQThjgsU+d4obV74R8IdE2GoOCm17mIFE= X-Gm-Message-State: AOJu0YwLSpknKQXXmC/6pNQu/U42sPhyVSSZOOsUaHcDUbKSu8o71uqm XZl29zjxrZivrcXhnfyR4vTxjfaooytt55Bhy5KNZAr7yqv7mg4EWk09AIZLPllO4mNPlUoVuEA keA== X-Google-Smtp-Source: AGHT+IGhq4L2iZI0qjQrwTOUQOvU97/c4AmsbzpWcAXlY7wJJCThuhaIO+OEQIc1xTorafJYcExQaSO905U= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:3f97:69c0:dd80:bd4a]) (user=surenb job=sendgmr) by 2002:a05:6902:124a:b0:e03:31ec:8a25 with SMTP id 3f1490d57ef6-e041b10fd77mr20935276.10.1720735504863; Thu, 11 Jul 2024 15:05:04 -0700 (PDT) Date: Thu, 11 Jul 2024 15:04:57 -0700 In-Reply-To: <20240711220457.1751071-1-surenb@google.com> Mime-Version: 1.0 References: <20240711220457.1751071-1-surenb@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Message-ID: <20240711220457.1751071-3-surenb@google.com> Subject: [PATCH 3/3] alloc_tag: fix page_ext_get/page_ext_put sequence during page splitting From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, vbabka@suse.cz, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, surenb@google.com X-Stat-Signature: n697oticcdqhrtussojgbaq9kgeiqee4 X-Rspam-User: X-Rspamd-Queue-Id: CB2F6C0021 X-Rspamd-Server: rspam02 X-HE-Tag: 1720735505-321833 X-HE-Meta: U2FsdGVkX1+d5eYyg50YjB3A+kKMVfE1rqEFnPAAz3lrW+tsSH6qjqTFQxqRVosEqt5TeLM2v1yAeuVGO2xYY+1i3I2xfXgLFY3wCAFBvgdxsHB/Wcd5LPYCj1puJFLSNaKWThPHMUru3MK/FixOSUeMFlYFlwfUnmpIprPq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9X1GAhDrQYXirLc8ovC9ETTUpZvR+q7vbxNnDCjB1Wc0/FReCTs5tCTm2O4UVp5VuybwzsVBpNCSbFJQMD9dx4/fAWsqxEEzy81gyTNrOu3HhU2mCLN8ecm3EA6t6DJLlZTbbCqvK4Ug+ergsOIfx0VCQp0YlrF7fYXWn0K6pDuNtqoR7LorWRuu5aucSGX4LPrM6TyJKN1BpEryk2P+P8YpdxpMUHwg+HEq0IThpk2GsgiCnNzXBgZCLvuono+NxjTo8BLxV8olSO4fcIdWAEuuDoIEXVRBwy6qf4xyA70R0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.002205, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: pgalloc_tag_sub() might call page_ext_put() using a page different from the one used in page_ext_get() call. This does not pose an issue since page_ext_put() ignores this parameter as long as it's non-NULL but technically this is wrong. Fix it by storing the original page used in page_ext_get() and passing it to page_ext_put(). Fixes: be25d1d4e822 ("mm: create new codetag references during page splitting") Signed-off-by: Suren Baghdasaryan --- include/linux/pgalloc_tag.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h index acb1e9ce7981..18cd0c0c73d9 100644 --- a/include/linux/pgalloc_tag.h +++ b/include/linux/pgalloc_tag.h @@ -71,6 +71,7 @@ static inline void pgalloc_tag_sub(struct page *page, unsigned int nr) static inline void pgalloc_tag_split(struct page *page, unsigned int nr) { int i; + struct page_ext *first_page_ext; struct page_ext *page_ext; union codetag_ref *ref; struct alloc_tag *tag; @@ -78,7 +79,7 @@ static inline void pgalloc_tag_split(struct page *page, unsigned int nr) if (!mem_alloc_profiling_enabled()) return; - page_ext = page_ext_get(page); + first_page_ext = page_ext = page_ext_get(page); if (unlikely(!page_ext)) return; @@ -94,7 +95,7 @@ static inline void pgalloc_tag_split(struct page *page, unsigned int nr) page_ext = page_ext_next(page_ext); } out: - page_ext_put(page_ext); + page_ext_put(first_page_ext); } static inline struct alloc_tag *pgalloc_tag_get(struct page *page)