From nobody Thu Oct 2 22:39:58 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 893D228853A for ; Tue, 9 Sep 2025 23:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757460858; cv=none; b=fU+WB/CeDaF6txzF8h/Bz8eFyNDcP0pYutXTbmnX9g435BcrmHLAaI5a/xIeALoMqUL2SBFwGL2JPB8CG6Bz6EFjHahT7MfxNTIvrboTu/Yb2StnOMj5sBXcLSl3PnZUl26HJlkqChkUmrVdxwRC6u4gvJ27NSU5Owd7FMrzdqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757460858; c=relaxed/simple; bh=z45BL1hbRzWmiV9tDqYSyXHWrtt4agT84wCssQaRrK4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aXcSsct1TUhO+3qXDB0WIAeQtyxpnkkrfXioiH0ocCyibfbnoDN38nyGy1BbSpGM74uTA2K4ClsshDiBxvxlQIOiPyP5ZvaZOvIE6kFplSDvCYVeezDpWkdfvrtDQ7WheYyGsQQdTiqBcjx1RPsRoD7ep8HsMXejET42SomTDlU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NiUJjQD9; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NiUJjQD9" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7724688833bso6470954b3a.2 for ; Tue, 09 Sep 2025 16:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1757460856; x=1758065656; darn=vger.kernel.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=p94KfP38ehFFAQzIc4UYzAxhmkH/aHIfMEPOUg/9po0=; b=NiUJjQD9ooyqUoJyU1rod/PXOitAUnLpI4TZg9sMGhB1i3qQVzuJ/ApUJtaPwYggZo PoLaFLMHVBjGhOp0G3sX09TZM+DH49H2e2NgAjj+2WoiRbzWqt8el1ZMnSJPRfgx7Rnb c0KZW82+2a1A+9Vd2Iu2P2XMLLXQH0/lUftnTa3GJek2NEaURmex4hOqDV5vn8mxxFaA pNBqFlajs/9Cido1qGG6Uox/UaGjc+8Y2WjkfBQj7MP3X4RDYdyi6kpy72TCKnewlCo1 ZScMvc0zPvep++lxtieATHfs2ncRik+eJMRoYF04mC5T7xIhgmTMa9W7QlhgkGOonf50 dBVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757460856; x=1758065656; 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=p94KfP38ehFFAQzIc4UYzAxhmkH/aHIfMEPOUg/9po0=; b=oeVv04kRUwPvlDWpjVPyf3EJXqy/a2+QX3n2Tql4v+hjvunPlbkMpmh8odzIYeGDzf tvXs7gA7SZbKHTmUYQ2AT/qCj5YnMfGCjS1y/PEu8oYhSnxWN2izCw7G0ttj+DAwtKnu ItAt9vqXEYnyVKcIavoES+gWSnR8+BU8X1w0AbQ2pw+L38G7cGAAOaBupzs2Xdahivo+ oDL0GgcSoRDhwll28pkxtp42qVIjxaZxlat+sqUkwjPct+dFsIbg+/Vx93Zdr4nc62t2 3eN5uJeJvwTTa6MpmIQ0vhZUhnR9rxZFSrF27EFrkCfIqNKls2gCZvd43fGl6jH3uGU3 EBcw== X-Forwarded-Encrypted: i=1; AJvYcCU1dCefXD5LRB93IV/43FgfFgdBTKvfqSBWL3g37f9hk7pweOWkJkaOXzHn9YAmWPWYkAxLU8YE1wp8guc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+ZaiqWM6SSQekyAeNF7Z14fw/XCshfO9SP3BZaskYM7pWbC7K N0OLEMP7Vo4b8u2ujGlJjglvuIqEKBg03YkqGYF6Qwn3I8fNLjWbeRTnOjgT89o8ayjyWpPaCTG l8ROMbQ== X-Google-Smtp-Source: AGHT+IHe9jU/ZXDF3VrMHA2zefxE/BkTlf3fesT6KUXKBfH1fEUS5JMtiAufZ6h2wVl/I0nMlsowMm3ygQk= X-Received: from pfbbm11.prod.google.com ([2002:a05:6a00:320b:b0:76e:8d8d:6652]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3c8f:b0:76b:ec81:bcc9 with SMTP id d2e1a72fcca58-7742ddf0f22mr17694356b3a.21.1757460855691; Tue, 09 Sep 2025 16:34:15 -0700 (PDT) Date: Tue, 9 Sep 2025 16:34:07 -0700 In-Reply-To: <20250909233409.1013367-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250909233409.1013367-1-surenb@google.com> X-Mailer: git-send-email 2.51.0.384.g4c02a37b29-goog Message-ID: <20250909233409.1013367-2-surenb@google.com> Subject: [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, vbabka@suse.cz, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, usamaarif642@gmail.com, shakeel.butt@linux.dev, 00107082@163.com, pasha.tatashin@soleen.com, souravpanda@google.com, surenb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When bulk-freeing an array of pages use release_pages() instead of freeing them page-by-page: Suggested-by: Andrew Morton Signed-off-by: Suren Baghdasaryan Acked-by: Shakeel Butt Acked-by: Usama Arif --- lib/alloc_tag.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index e9b33848700a..95688c4cba7a 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -438,9 +438,10 @@ static int vm_module_tags_populate(void) if (nr < more_pages || vmap_pages_range(phys_end, phys_end + (nr << PAGE_SHIFT), PAGE_KERNE= L, next_page, PAGE_SHIFT) < 0) { + release_pages_arg arg =3D { .pages =3D next_page }; + /* Clean up and error out */ - for (int i =3D 0; i < nr; i++) - __free_page(next_page[i]); + release_pages(arg, nr); return -ENOMEM; } =20 --=20 2.51.0.384.g4c02a37b29-goog From nobody Thu Oct 2 22:39:58 2025 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A718F2B9B9 for ; Tue, 9 Sep 2025 23:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757460860; cv=none; b=cRHn5MWimMbN67Ar0C6lsq0DCc8L1tRTXFVWBZRB5qSnXojBRiAHOtyXEZD3kw4u+7Ur45xf43CUfQXeCspF7yF3orvMmQJ56/i3O9lJDOqs8ZVA1Cm0rilqgsTNm86ljZvNYYeN4YQpwhKtgJlmj/PHmLTRsXxhK0dk8P+7PPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757460860; c=relaxed/simple; bh=VRVXvdyBXu+l8eN5OmWMKeoSEG/KMU7MEJ8tdydrdIQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mRhGzAR35hH2QY7LbJ9dTBC91WPdoGRO9iOT5rkIgEYq6iD3yjIIEFVrxiZ7P+ZHiK3V0jqLEJ2RhWmdVc+5QKXk7so3BACq4djhpzCz48OgN4hlZu7ETD+DbXxM3VDE/XiDI9+7rANSCX9TB6LlcMpULeIri4ITSthZNDsqo8Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=LL2Jixij; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LL2Jixij" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7724877cd7cso6940662b3a.1 for ; Tue, 09 Sep 2025 16:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1757460858; x=1758065658; darn=vger.kernel.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=K6OH97ZpoRzs/QnK0sVtwK1+CTMH7EfEmnF9tlYLf0g=; b=LL2JixijHp4p1q/v1EkyCc3FzMk/nZ4MiZtAKu1dmoWb5CJS7cu0DrsGRwxF7pPqWL CPn5NFgs7KpWMwO0inANqTiZE/pj8UnZJ/gdryEjO3AhkFcu4kzrtuI2DhPkLT1R6Vku 7XZrJVx8YGl9nhoAI00X7rn9K4pkzYV9uOb4nDSKHlagN6DqOlPs2DGW19t5Hr5PacS4 mQriNQrL5Tl4A/gEkuSocRdWzqhOguOF/ItnOr8xDVhi1qzPYgsCfz1ziYdrIcw2DRVk S6pperryh9m+WJrATXD4TgRISM0Shq8WRJ0HNXqpXTCuln/C6+0GBZnzAtOtuo2NhK65 c7nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757460858; x=1758065658; 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=K6OH97ZpoRzs/QnK0sVtwK1+CTMH7EfEmnF9tlYLf0g=; b=RwtWKvkgKdHkDPB73BJgZMdIqhdriR7MZKFrvVkieZJTBhVNnq4KiFbSWmRRJUVsgH RM2faiuJYmACJlPMs7mL9BgcQ2if9g3HLY+VpkiNeUOH2wcw6nwJfE0w1zfKvK0c7Ii7 bCCHIAG62MsVbxxS+yw5Ycncj/uv1OFOhnH19lgbIejO1fsuQtvgE3IbPUZth98VBT25 gZKeGWzJNCct50Y+y+BmNb6igHoau0S0B8KkygbMh4QIAgxGSzXk7JrCC7L7RQTBhA7v 6OmUheLN4fMb0kzleIzV34LINJiwYwTj59L9FJFLKm5MuYRFAisvlS2qiA69UUAUv6s8 EVkQ== X-Forwarded-Encrypted: i=1; AJvYcCUxmeTf1MwlNlBnGILMiCiUY/Cke/nX21+BbLHZ4J+NRZURtatBfoOb45T4lnnUJQrm6W6lWJi1w8C7IMU=@vger.kernel.org X-Gm-Message-State: AOJu0YwXHJeQFvH9htFkX0NQlnb2WRdYH79JFFPkCegb1b16PZ2p0+Sy rtqzMAfvv1nFjsG2dk8Z9WPsk3/dF5Ze1x99BM7KuRCJdtyJIdY1VRyJ+XKK+yK0Hhe/h1lSffB KzMbe+A== X-Google-Smtp-Source: AGHT+IFIst4jd2D334Y2PkPuCO/Ean4Ij3IT9elqE1huVfZrndSK+83KyXPa67AggUAs4pMR4FIui+Zixgs= X-Received: from pfmm1.prod.google.com ([2002:a05:6a00:2481:b0:746:3244:f1e6]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3e14:b0:771:d7b0:6944 with SMTP id d2e1a72fcca58-7742dca536dmr15166038b3a.3.1757460857845; Tue, 09 Sep 2025 16:34:17 -0700 (PDT) Date: Tue, 9 Sep 2025 16:34:08 -0700 In-Reply-To: <20250909233409.1013367-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250909233409.1013367-1-surenb@google.com> X-Mailer: git-send-email 2.51.0.384.g4c02a37b29-goog Message-ID: <20250909233409.1013367-3-surenb@google.com> Subject: [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, vbabka@suse.cz, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, usamaarif642@gmail.com, shakeel.butt@linux.dev, 00107082@163.com, pasha.tatashin@soleen.com, souravpanda@google.com, surenb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Memory profiling can be shut down due to reasons like a failure during initialization. When this happens, the user should not be able to re-enable it. Current sysctrl interface does not handle this properly and will allow re-enabling memory profiling. Fix this by checking for this condition during sysctrl write operation. Signed-off-by: Suren Baghdasaryan Acked-by: Shakeel Butt Acked-by: Usama Arif --- lib/alloc_tag.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 95688c4cba7a..79891528e7b6 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -767,6 +767,16 @@ struct page_ext_operations page_alloc_tagging_ops =3D { EXPORT_SYMBOL(page_alloc_tagging_ops); =20 #ifdef CONFIG_SYSCTL +static int proc_mem_profiling_handler(const struct ctl_table *table, int w= rite, + void *buffer, size_t *lenp, loff_t *ppos) +{ + if (!mem_profiling_support && write) + return -EINVAL; + + return proc_do_static_key(table, write, buffer, lenp, ppos); +} + + static struct ctl_table memory_allocation_profiling_sysctls[] =3D { { .procname =3D "mem_profiling", @@ -776,7 +786,7 @@ static struct ctl_table memory_allocation_profiling_sys= ctls[] =3D { #else .mode =3D 0644, #endif - .proc_handler =3D proc_do_static_key, + .proc_handler =3D proc_mem_profiling_handler, }, }; =20 --=20 2.51.0.384.g4c02a37b29-goog From nobody Thu Oct 2 22:39:58 2025 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBC7C28B7DE for ; Tue, 9 Sep 2025 23:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757460862; cv=none; b=hgyJcjADOP5YQkF8ErvgKGWDH92LHUGhq06+smP98bGat0ySmi1U/UbSGaJfQQjhO12+MzHDKXyNj20n0vOdMfqG1VdvWwVa68KffPwnW4zrmI25TcHKoywN7XjaYSOYCuTdb6kQzuK00BeyxP9XRhyErGs9uJIofIkMXAsCDBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757460862; c=relaxed/simple; bh=paM9mBGyRaI8AAQ1YFJDdCA9Ntl8aRb2Pn6q4fv7/iI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=h0KL/2C+0tyCcQ5qP1qEEnGPqNxnxQQgiiZCD3y9T9QrL5LTIAANU9GT3R3IP759BkEb6afn7D4g205UtEQ7qO+hqG3ApkwS5V/YDayFIDAMqn98//ALWrwxFuB/LdauYb7GcLKSN6VXXrlzPd0aSzgu7q6AiOYgxvf18ZhX3rM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CXpLEtH9; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CXpLEtH9" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-77429fb6ce4so3977036b3a.2 for ; Tue, 09 Sep 2025 16:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1757460860; x=1758065660; darn=vger.kernel.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=9D+kUp+8/PWIFjKllG6CENhJfl0f54OgddsYmF4lYnY=; b=CXpLEtH91peSjvKDBvW+CuOhHDDyNuZvWhrppc9+VIB6IKtVcTjJfXPb7Qr4Xeg+87 BnDXh9SI4iiJC7uoMaBA9/ou9FfqzBvMf67aK5EAVM71cI3vkc1JsiSdKlPxa6jHQhoW 84Ujo+TLm1gjWQjGZNRT5BANuN4V+72NuP0d8RiCsDKXt68E5HDxPDI+RI5FfpkGXcq5 AMBtUd4iIrZ5HQJyTTeF7jG0NnQ4K+EuE12COR1Pbj1t8ihsA/qrpboh220EVgO3MzfF 2ues9Ay482g9J+vPxPnpaZxdmVcC/+9X2dxlQQgb8wV2rjZY6ruOxrUBMdbYUWZZGY32 VeGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757460860; x=1758065660; 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=9D+kUp+8/PWIFjKllG6CENhJfl0f54OgddsYmF4lYnY=; b=sYVmVSBThMRj8BWPwkb0/w+lx2GcbmusRJ3Yl81CBNXDiQrWLZRzW36JTyK58UaDdM T9kPHmIp6pXdtCPpvSCoZ7A317Pl7tQWQcJZxckKjPAq1DPj9NDDgqA7Um62+Tf0ePEx hC8NnLYHD4XiSqjzZ5rhgZ/l5iIsrUS15bREDBEUfhj9X7iTPBlqX5h14QOsHk3IZku9 UzCdjzz6BdPV3TLs3bHg5uTB+fq1M7Hgks09z7mGrRScYXnMUZBw4UytWoJBastyGwo1 o2xAuHg2rqRjNIEOmzdmWkFapTdQrsdu8QvRiHPV/uJCTGyKw0OWBlUpPxBpT2QR7piQ Jnqw== X-Forwarded-Encrypted: i=1; AJvYcCWIl94VSNDkBscEG9vaAPj0fGOdfLCB+LTx0EE+sMf7X2CKHts+BOcoFJdvoGq3qch68VAkzCF92ux5ezM=@vger.kernel.org X-Gm-Message-State: AOJu0YxqPF5zI9XceXnFvSvn4Gr5tB37oH4WvZOBS39XU3jaKNh6z9+D JszFN4Cd3VQbrkzDVRNnbNjvLLYBf+L6Kcvk74onC3YBkJwqTXfSv8resPXzNFOuCY/BrVZ9MXi hb5JnWQ== X-Google-Smtp-Source: AGHT+IH21M6CEVT6I4cbVbLFhLsLvsvyph9LaEsNMJBlcaaK/bkq0Ym1zULWMNoZDsLFG63V/okgQHCwDiw= X-Received: from pfbcj20.prod.google.com ([2002:a05:6a00:2994:b0:772:701:dfa4]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:14c2:b0:772:80d3:b684 with SMTP id d2e1a72fcca58-7742de925bemr16942717b3a.22.1757460859886; Tue, 09 Sep 2025 16:34:19 -0700 (PDT) Date: Tue, 9 Sep 2025 16:34:09 -0700 In-Reply-To: <20250909233409.1013367-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250909233409.1013367-1-surenb@google.com> X-Mailer: git-send-email 2.51.0.384.g4c02a37b29-goog Message-ID: <20250909233409.1013367-4-surenb@google.com> Subject: [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, vbabka@suse.cz, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, usamaarif642@gmail.com, shakeel.butt@linux.dev, 00107082@163.com, pasha.tatashin@soleen.com, souravpanda@google.com, surenb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When freeing "tail" pages of a non-compount high-order page, we properly subtract the allocation tag counters, however later when these pages are released, alloc_tag_sub() will issue warnings because tags for these pages are NULL. This issue was originally anticipated by Vlastimil in his review [1] and then recently reported by David. Prevent warnings by marking the tags empty. [1] https://lore.kernel.org/all/6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.c= z/ Suggested-by: David Wang <00107082@163.com> Signed-off-by: Suren Baghdasaryan Acked-by: Shakeel Butt --- mm/page_alloc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1760346bbd24..d21a411e807e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5240,9 +5240,16 @@ static void ___free_pages(struct page *page, unsigne= d int order, __free_frozen_pages(page, order, fpi_flags); else if (!head) { pgalloc_tag_sub_pages(tag, (1 << order) - 1); - while (order-- > 0) + while (order-- > 0) { + /* + * The "tail" pages of this non-compound high-order + * page will have no code tags, so to avoid warnings + * mark them as empty. + */ + clear_page_tag_ref(page + (1 << order)); __free_frozen_pages(page + (1 << order), order, fpi_flags); + } } } =20 --=20 2.51.0.384.g4c02a37b29-goog