From nobody Thu Oct 2 14:24:24 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 8C84C2C029C for ; Mon, 15 Sep 2025 21:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971684; cv=none; b=ukJerjZ7GY1NxHi9emuNve5pRPDvnTHtuNTZohcDZVTy8hNXZEVTrE5nUK5dFNpviMzcOXaxi56Vh+M7+cGLhG32Awl2JWZ0YWeBQvgCHfP0+8dMCBf9KwCELeLX/QgLLfSgjoO8aurTaQwmepixcFNKFmfrutl+nnW7jyKh2Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971684; c=relaxed/simple; bh=BWHI3euYFhYckei4nX2XlLs2/iu/aWT7eLB3tkhlhVc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nhzJ4mJTSiJdY+LkuSz3udNxLVMP44Gh6p3k6Q95rtrt0y04nFKN943HzBADaeou8oW9u5Fw5HAXe7Rd33aVybLR8CheH/kUbFdKv/oycxON0BAqRLcvUxH0rNo0XEj5PinFJO1tcdepmtUPuPgtOYkC9ipHpUbdj/t86be0hG4= 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=2RoJMP28; arc=none smtp.client-ip=209.85.214.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="2RoJMP28" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2675d9ad876so15510015ad.1 for ; Mon, 15 Sep 2025 14:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1757971682; x=1758576482; 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=d2Hz1JL08Ae9YH9Hn+DIDbn8r5v52DDgbIHCorDchyE=; b=2RoJMP28KLpFDlozZJ/PqzDGIapebFpvroX2agwaMIf9SC+69nzhenC3vYcYPOvrHf 94n3sK8IqCEjBGSrLTIA+CY3QWumsEFB9VIxYt+T0GYoSqZni+4fCzWTZlg6Je4SeSoZ dZ4NnIztnRU+SZvx3GA7owKsPjKUM8pLwmFmN2x6B0yAPZDDB14Gc1djFFpgYw09XeYJ x2r08dUVgLY0ChaewSvaClCm24gBFte1D+syTRBo6NqpuvsZw9jKAAosz8oUalYljZr4 6Qk5FF/kX3zANqJIg4tdQa96lBUO7S8XaI1Ho762ZLjhEIlpod7BEu0qd8rfgsAfLpNx kkCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757971682; x=1758576482; 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=d2Hz1JL08Ae9YH9Hn+DIDbn8r5v52DDgbIHCorDchyE=; b=WpKMCv4F7vEbdG4nxVsg03hIdkIXuSF6h8mUy8x61xb4crkBVRytXzKiQDe+WG11rm nfpMnBW6JhT3HNtqBF+FvMuRR1jYYStaONhfS5y4dFmG5wou97VloZl0mL+AnR1lvUHg aBBETxuonJskY8A21JydTHJrwM2pM3OQKxdgJdg/s24Jm0khNeQfIzNUErSKRa7dniqb rg2UhgJzC5zVZaNEXrN4h4HuyBTPPl6uwVbhbDtALJy/Uva4hwEbjeptZkOk1GqgEvCE iytLPVnJfaEEVS3KgfC//aTvgBd08uZDYxI12Uf4TaqBiqkgDT+0J1/I9qCVcIw4HZJC aidw== X-Forwarded-Encrypted: i=1; AJvYcCWnTR9zXqLj3SBF5vwAKG7D9gO9rpg677qVuAb9fy4fmLHb3ri8xUCOFEjOoCMr5s3d1RfJfg6LQlFcff8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7ssPou+tlBfyXOQLiHkQ2FNaKsDZxlepadGQLD4eR1ToIAZQX n0RMZHMKblzlDJkr8fdBl+C0R0dw6KqS1fZ8bM/JRNJojVpreiO7wTID6zxbMIyBVRsfVYvCHiy fgD7lXg== X-Google-Smtp-Source: AGHT+IFXwkTqMiXydSMPHIxdCSNKA0S/hLuGJlzEf2CG2PJ0l2U3kHl7v2nc4f6XLR3nxDEpOSny0E2guYs= X-Received: from plar21.prod.google.com ([2002:a17:902:c7d5:b0:265:9878:486c]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:22ce:b0:264:4e4a:904a with SMTP id d9443c01a7336-2644e4a929cmr82325055ad.53.1757971681831; Mon, 15 Sep 2025 14:28:01 -0700 (PDT) Date: Mon, 15 Sep 2025 14:27:54 -0700 In-Reply-To: <20250915212756.3998938-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: <20250915212756.3998938-1-surenb@google.com> X-Mailer: git-send-email 2.51.0.384.g4c02a37b29-goog Message-ID: <20250915212756.3998938-2-surenb@google.com> Subject: [PATCH v2 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, hannes@cmpxchg.org, 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 Suggested-by: Usama Arif Signed-off-by: Suren Baghdasaryan Acked-by: Shakeel Butt Acked-by: Usama Arif --- lib/alloc_tag.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index e9b33848700a..715315f5d9ba 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 @@ -682,11 +683,10 @@ static int __init alloc_mod_tags_mem(void) =20 static void __init free_mod_tags_mem(void) { - int i; + release_pages_arg arg =3D { .pages =3D vm_module_tags->pages }; =20 module_tags.start_addr =3D 0; - for (i =3D 0; i < vm_module_tags->nr_pages; i++) - __free_page(vm_module_tags->pages[i]); + release_pages(arg, vm_module_tags->nr_pages); kfree(vm_module_tags->pages); free_vm_area(vm_module_tags); } --=20 2.51.0.384.g4c02a37b29-goog From nobody Thu Oct 2 14:24:24 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 A5FDA2C0F91 for ; Mon, 15 Sep 2025 21:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971686; cv=none; b=lLBrB2HDZX8EMZbJxyaMRRzYd0EpdZQyQAIKyJtBDpw6gcFGNW2IgKbW4mXmSSU9z3usUZenNQwvR6WGvcBrc8FbMdOYlKlqQdD2lemw3TpyLQ/m1taupPWuMw5Z89ik+/lREdbNkv5MGtM/XQAjgYRAIbWrahyQeSDBf5CbZk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971686; c=relaxed/simple; bh=ZYjsZu5y682FqE+uKVWDmTrQoUxx9+iRbsMKxGzoJxE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WGbXtpbGUj2QDHJEX4hin627pzYmI6sRJRZx4I4mxR66m7yqzp07tpolw5HQpUHhRi1Oa9H7X7oyMFFgSTm+pv3dCvBOe6A6uFMtL9UpCKd7DkKg2bNet0KPq3tT0/MVqwVOi3S3hiLoismJOgtSRh4XnUrAa8cAOu18AVqhAYo= 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=cgBXY5Ny; arc=none smtp.client-ip=209.85.216.74 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="cgBXY5Ny" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-32e0b0014d9so2178778a91.1 for ; Mon, 15 Sep 2025 14:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1757971684; x=1758576484; 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=T3medVd2qOWPEhfNfxl2kAO69G86t9hZitkKMHzJnpo=; b=cgBXY5Nyf58ycQjJm78UPyMep7EvbdcviX/FSjiQm5LXqbqVraLtk2qg4ssMBrOthA BhG3C83dN5HE0jg/ycbpD7TybL5/1Oitz7LBazXT44HuU//UINT+SeQy6JGKKxEFv0Wi PRuIPOyyy84/8QVfWXFeavZLEwiqbFCCOthoBIZvo1aoA0IpdkQDJbfrXfn9faVLqjxZ rz6n5BaVzzzw/eUGWQsRjNjZ46/u0ZCRZ+FylQAaxZMnP4Gb5Iuo/umTe4cvZl7muMWN u5j21jy4eVCfXqQ/addj5irfv5K5sLxtu/RGgFucDCF+6zU7NYMltJdLSuqF+zQkHuWD Sayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757971684; x=1758576484; 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=T3medVd2qOWPEhfNfxl2kAO69G86t9hZitkKMHzJnpo=; b=VhrM2ZicB8ox5/ChLUTD3p+U/hVCwwnvganASoBSVz8OnYnrxDn0dw3kd4b0uR4hZ3 dKeDTFFVNfXJEI42IM2eEtrPQurN0lfvHfYk2MOfHjgvaOS3pz8JLPukc8udnA57Dhku /vPaKSsqFSM14Cg1cd+VkiImP+v44fliMojI+jBy1Z9o9Ji/wP7fUP8er5+NFuq5/2/l X+GRvqH6AC62GuHr058ltDmUYshNSyvmgQTFujjflmyYVA00/DXkOIHmZ/1V0nv0weQU H/IPDGxhJvIQSYmWUP659R73VvQR3rsb9eBgoj711VcmArTiSm7SviqKa/xyYNizXnoJ cUfA== X-Forwarded-Encrypted: i=1; AJvYcCWo0cRuQX66MCHfWdtS5sakTd0mv5BpnUesH1BVU0IoAytRfg6OadrRTuWzL8smW+YefSwySIYxXy0WrHI=@vger.kernel.org X-Gm-Message-State: AOJu0YxBDKLWm2OJUgq0a4WqUuCrGMx5/1m/myT4TYV3hLLKdBK4Z1CP HJYsfZv+9cb1qmyevyMpDgXbYGbiI/g/uvp0Q/XoL1oDO/nUcrYkMHIQLM6408b2SGhChuOX6mh IYIqKCA== X-Google-Smtp-Source: AGHT+IG0byYP3KTrWemnIN9/oKJgT5zEjyVGWK/0nxIQCBnj0mlAmsfNkBFjneyG7fIPiFxNWh348vRy8yI= X-Received: from pleb12.prod.google.com ([2002:a17:902:d40c:b0:264:6a57:a799]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:3b88:b0:246:eb4d:80c8 with SMTP id d9443c01a7336-25d2675de07mr140073345ad.34.1757971683955; Mon, 15 Sep 2025 14:28:03 -0700 (PDT) Date: Mon, 15 Sep 2025 14:27:55 -0700 In-Reply-To: <20250915212756.3998938-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: <20250915212756.3998938-1-surenb@google.com> X-Mailer: git-send-email 2.51.0.384.g4c02a37b29-goog Message-ID: <20250915212756.3998938-3-surenb@google.com> Subject: [PATCH v2 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, hannes@cmpxchg.org, 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 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 715315f5d9ba..f79217427d81 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -766,6 +766,20 @@ struct page_ext_operations page_alloc_tagging_ops =3D { EXPORT_SYMBOL(page_alloc_tagging_ops); =20 #ifdef CONFIG_SYSCTL +/* + * Not using proc_do_static_key() directly to prevent enabling profiling + * after it was shut down. + */ +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", @@ -775,7 +789,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 14:24:24 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 B2F812C11D5 for ; Mon, 15 Sep 2025 21:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971688; cv=none; b=fccM4vVhfhaabyklABqRKGBzvZddeHf+1+65i7iz69W9wHhFPWjn9iy9U0lGAW7c7SOpd5dSUZWzv6Zd4xO5ja46ffST5p60kx+R0vMD68dSlVkhc94Ze7fswxfQApyL0AhBAiGWYQEUu3xg0cHNjp9L6TlsOuGKGG6JJX/A6Wc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971688; c=relaxed/simple; bh=JAKRLFebOpbcyKXt+Iou4Yo/KY8c1E/crm+zwHsW/QE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mClA8upZJZXoMlKlzExj5/KuhJBEI598T4BnZrXQycAowDMYpGt9/Mrvb+CZFMBDXHn/MkhRHovz0vEwoIkSANOJn78u/7FN8f+OxLxq6WO2hDpY+tObqrgB689keHnnZ/dZQoOV6Y/nGXtgCpW22p0bnE/M8ioS8CS9TvfLy/A= 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=ETnzgaJY; arc=none smtp.client-ip=209.85.216.74 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="ETnzgaJY" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-32df93c793fso2666559a91.1 for ; Mon, 15 Sep 2025 14:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1757971686; x=1758576486; 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=9fEJ6IElFOeZzP9UWymvXhcSMMsB3bmGnSn0zKtn7xw=; b=ETnzgaJYufxMTTcRGVMsYAkj5YYz/vkLNdz6y2e6g3tvRNcEOHneww0QhCuk3OLOt8 3pGgx3DQDPjE1GD799QV9iBDbkVuZ/si7cJd0cIBUY4jmtI/08jHe1+a1LMVUwk3MMTb rfUr1gNe1xH68CuJldrnucHC1PB1ql55AV/AzpvTJGh9zmxArClVGCA90WciEKrIXMO8 gwd3OaRk7cZi71BMKXJSkKXQTNzSccyyC/DWS46aeKSIdbeMXlE8VHj65NilcMj0FA4X oTxaTQ+XJTGXo4IQAaroIZspA46+AWiJtT5CL1i+6MhhznWg5iue+uSOtg126WNraq5f Tpxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757971686; x=1758576486; 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=9fEJ6IElFOeZzP9UWymvXhcSMMsB3bmGnSn0zKtn7xw=; b=PPtdyzkt9L2s/qTa2X2QVZ9p89hCHzsIlKc4PmzpX9F1fbOXy48jWWvWNbVwydSt9b 4TlaKZPiDJSfbi1/ESMOfEpBJ+ZyN5B4Vh/V3F/4Rta4jQLyQrMAb5pra1kOEFYgdfHV 20WJQy8wbjET+tB5n1iX4EeGMJQsysA/lZo89+ZD5JdySmlmnmRcQ7GMW6eR8kvK2F76 c2H5Ra6jK/hB6dp7PDQAJGFVdWh//IBv8MHep3TShO/HDgARd66LYaOWFXdfT2pGHchi 3R68UnNFl5aRh0Nu2Iy8N9UgbbXHjsJAlOE+D9iAZJ+7J0b+PxOFjA1frUIjoGGj6jRh R45Q== X-Forwarded-Encrypted: i=1; AJvYcCUJPIDVYRA+aM4JEctmivT9xxIYKW+m7yg3FscKqaSELMDcTOwoR7G5gOQyZxbaKVaN7O8vsbLN9NAtVXE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9JGlYoX7S5Yp5hssLjVKDS7yO3FDKHFTvK4MV9BKLw1oNQPIt kvAvD4dIYNZSSnec0OA9iaN4X6tFP3lVL2hWE/fcVtYisYUD0lo+uIt2ZW0qPCOlvW9jKaS1m4/ Kl8okQQ== X-Google-Smtp-Source: AGHT+IFJUPo9LPvtAkRuwP8Wle8PNDVxYyAftN39GDpSH2OdOqb+BpCFXVNO3SkD0W3Pv7ttuYAJ7A5yC60= X-Received: from pjtq15.prod.google.com ([2002:a17:90a:c10f:b0:32e:8396:7798]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4ec5:b0:32e:8c14:5cd2 with SMTP id 98e67ed59e1d1-32e8c1466b2mr2709252a91.28.1757971686028; Mon, 15 Sep 2025 14:28:06 -0700 (PDT) Date: Mon, 15 Sep 2025 14:27:56 -0700 In-Reply-To: <20250915212756.3998938-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: <20250915212756.3998938-1-surenb@google.com> X-Mailer: git-send-email 2.51.0.384.g4c02a37b29-goog Message-ID: <20250915212756.3998938-4-surenb@google.com> Subject: [PATCH v2 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, hannes@cmpxchg.org, 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 f54c5ee1e318..2bfab96c207f 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