Message ID | 20240202190628.47806-1-urezki@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-50462-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp644546dyc; Fri, 2 Feb 2024 11:12:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqPda1PP4ElGg2x7dEmb0C/FYl8y4o6tiwt29BdGZlqpL8gJtcayy0lYy9UU/zBmRxXWfh X-Received: by 2002:aa7:c24d:0:b0:55f:92f4:15b5 with SMTP id y13-20020aa7c24d000000b0055f92f415b5mr468230edo.23.1706901147488; Fri, 02 Feb 2024 11:12:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706901147; cv=pass; d=google.com; s=arc-20160816; b=wy0UBWZ7vW7m4+jJ4Wh0JAd/9WPsjDaYJpRafVrjYPv9Ifo1TKkh92eOUc/U8WLJIJ YSgWOrhbDZ0Do0f6weP237endLihH2ztGmi4N7Nau5yTQ8H1m0emIMvigDG5u2EzlabA iabmvSdR8OptWhxee7g6C28zCP/VNWODrUzqw8Adwwy+CNps4jpJS4rnttOPLB9QVvGt L0gJDp+KEb8/vKwn4l7udeDhAxSUOLFrlLfbky84XoKb3T2I0z4cJBBJSsjBpctgKy9z bczAc1aXCU592OZLMQS9YTWIm3lYRmIC40bnzs3n6acuom/tV74tPBDegCQJcRbmHiJk X4FQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=EfyIjo6kez38DeVdB3upQeRKk1i+rP6oI+i6zlaUfoo=; fh=hQZ4DowyCJK/xARX+i+FSsEzNYGVVbQSpbsd/E9Hy4k=; b=X+4g10ybV1Ar3Ig0PTkSZGCUrgEUUID53GEccYNS2FEr4pcf7Y+wCU/S2gMXHq+Pxk boq9bHBBm/g3mHod5Io5+UK1Vyo/7SUCbmlHIeO7Dv1JbjLQYts3zO5+SGjKFgclcxhy ZLIb1okbBPmig6tKQSo9uj2V/SeLpxO0Tiogqoa/gysle8Yo7eQ+mD/URh4RuDiYz7tr nDdxP+zRPtbDi4H+oUn36finJavSeYdMf6BThjqtNdgB3M2hyMTaSb5bpGumnHaHcYRT CB+bb33mBY3trDGdgoBj+EkDqX5wikhsCm57DzbSK6jjcjKoEOC/xbs5x00iRi63ck5M YCJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=geWC4g8l; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-50462-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50462-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCVrFaaZPmNig4ygf9Xj7JgtFnSVO/Omkjy15YI4PNLKS/wfmxn3n+yEy1CeNqw3dw+4D+GjxTtkOfGmMgLfV5DhK3BbxA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cw10-20020a056402228a00b005591fde7b64si1063719edb.216.2024.02.02.11.12.27 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 11:12:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50462-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=geWC4g8l; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-50462-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50462-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 139561F219F7 for <ouuuleilei@gmail.com>; Fri, 2 Feb 2024 19:12:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 190B3839F3; Fri, 2 Feb 2024 19:06:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="geWC4g8l" Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 C395F839E5 for <linux-kernel@vger.kernel.org>; Fri, 2 Feb 2024 19:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706900795; cv=none; b=nDUajgRocGN8/xumc5JrxonRkynRICd2M9lvrx3D2QT81vItiTakS2ltwd2YLsgpIQ8GwuwO8TfPYuCOnZqsr7+jsFZcTGS0oDO6k140DS6qgyLQ1dSRwvkxyTN3sssYzuJapHAiBSF0ifUtAesXO6noIl/F44q5dAo3gveF760= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706900795; c=relaxed/simple; bh=rNWqum3/yYvzJfhaZjhWCaFc1cTDx8Mx6rzWVIVoCyU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Z/dpxp3+FAtTW8O2oIfJv/luEru16U4n18O0sYCpKYO3R66tX5nmHoS3upIYPPFz7atVUrhMsXFgnX+ixngRtCgXxu791TM43tY2/F+eMIOcFv1wVrbDT4r4CqnQQH08Wyws3WSIueJgLifB+nRkQkxvj76AOiVHbc3h5YnNG6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=geWC4g8l; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d081a0e5feso15508971fa.0 for <linux-kernel@vger.kernel.org>; Fri, 02 Feb 2024 11:06:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706900792; x=1707505592; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EfyIjo6kez38DeVdB3upQeRKk1i+rP6oI+i6zlaUfoo=; b=geWC4g8lliMc722fjCcD1BWfvohFaoXqVb9Be3c0PgDO/PPR9eoZhLU01u1/3H8dVD ET9ND7Wm7Jdl9UCfYLXrVfXzFqm9QO0o5i/HWY2IvgWRngKMa5vdFMgZ4Ol333oC3ZOw 6F6BNFz0NCKZoKbmCYTPy6Vl+51jEF9Y61lYab/YWImHfQHzcOr2zXIlcaH1OmGRqWtO B0PZddapIxsQjjqrGM678GmZLtAxof5KDbWjnzZaGSyfrLdNEQWo4O5l2GCu0hN51z+M ugay55elXL5XuDVjfm7swTj6HuuCEC95cg+g/WDsHt1lH1eZBc+eG02sFyxg5u1LygC9 QZLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706900792; x=1707505592; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EfyIjo6kez38DeVdB3upQeRKk1i+rP6oI+i6zlaUfoo=; b=ZFZt0Ol9HH1FA9oa1gmFKO3D9Qt1ED/K+tFsJtaJo6q63RD6dNc+tupmHl3LX591rt injweMMH+WFC2a6aZ/BEa5Dd2PfSJ3YoSX3qPEml/HFdZ87xkSlSmArAVmGmbouD44tJ w7IhLQRiVGcISBJ57K19hEB79QdzsAVIC4QV6mmo+U4bF58BDrKPOZ4i9nd6arL7EAP4 paYqpVFnzcVZH8H96GbfAVt5RzlUgo1bUgQSDbpUdz7eG824YypHwj1RtiMbflwDZ0hX y+s2pRumIy3jlWENOFF9ABDuw39SjNlSOoPXh4jr5HL4tl66QnOwXf2RVxY71qoNBz6V 5lQQ== X-Gm-Message-State: AOJu0YxTal9+1iA+j24pFBjeVddYvBRRvf245p+tXC/0E5I55EidjYjw Ueea0JFQcA/jHs+6EpffEMgRMXyQyQKr+mioGaduBrmUompqTpKU X-Received: by 2002:a2e:a4b7:0:b0:2d0:7f95:1e3d with SMTP id g23-20020a2ea4b7000000b002d07f951e3dmr2445991ljm.40.1706900791373; Fri, 02 Feb 2024 11:06:31 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWEOqqB5uM/ZmiUeUdHWjO7MY/KcV6nzIPGUJ31nUcBeA2L7eQ9N5NI7fkF8C37YuahFUEd2kOpYu8x6WYfnpb/LDj2OYIBKScbAfzMBHEM480SJzArDdTwjCEFkR41eRK3d7T5D0kzUy9ofYBPgAbNNtq6PCoM/9PHOBczPPmSEANnI8kMIv4O+vM5CUo9O3rw9jgdL+i/lqZh055QYa+xlYlPObGucrdfAdlhrng6hgo4rc2i4rxsKo3uXHCSlrLokST19mc1Hgtl/ZXlHyDocYZdEVHiY0qIng== Received: from pc638.lan (host-185-121-47-193.sydskane.nu. [185.121.47.193]) by smtp.gmail.com with ESMTPSA id y9-20020a2e3209000000b002d0522b2550sm353782ljy.32.2024.02.02.11.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 11:06:30 -0800 (PST) From: "Uladzislau Rezki (Sony)" <urezki@gmail.com> To: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org> Cc: LKML <linux-kernel@vger.kernel.org>, Baoquan He <bhe@redhat.com>, Lorenzo Stoakes <lstoakes@gmail.com>, Christoph Hellwig <hch@infradead.org>, Matthew Wilcox <willy@infradead.org>, Dave Chinner <david@fromorbit.com>, Uladzislau Rezki <urezki@gmail.com>, Oleksiy Avramchenko <oleksiy.avramchenko@sony.com> Subject: [PATCH 1/1] mm: vmalloc: Add a scan area of VA only once Date: Fri, 2 Feb 2024 20:06:28 +0100 Message-Id: <20240202190628.47806-1-urezki@gmail.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789815577709882458 X-GMAIL-MSGID: 1789815577709882458 |
Series |
[1/1] mm: vmalloc: Add a scan area of VA only once
|
|
Commit Message
Uladzislau Rezki
Feb. 2, 2024, 7:06 p.m. UTC
Invoke a kmemleak_scan_area() function only for newly allocated
objects to add a scan area within that object. There is no reason
to add a same scan area(pointer to beginning or inside the object)
several times. If a VA is obtained from the cache its scan area
has already been associated.
Fixes: 7db166b4aa0d ("mm: vmalloc: offload free_vmap_area_lock lock")
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
mm/vmalloc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Comments
On Fri, Feb 02, 2024 at 08:06:28PM +0100, Uladzislau Rezki (Sony) wrote: > Invoke a kmemleak_scan_area() function only for newly allocated > objects to add a scan area within that object. There is no reason > to add a same scan area(pointer to beginning or inside the object) > several times. If a VA is obtained from the cache its scan area > has already been associated. > > Fixes: 7db166b4aa0d ("mm: vmalloc: offload free_vmap_area_lock lock") > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > --- > mm/vmalloc.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 449f45b0e474..25a8df497255 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -1882,13 +1882,13 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, > va = kmem_cache_alloc_node(vmap_area_cachep, gfp_mask, node); > if (unlikely(!va)) > return ERR_PTR(-ENOMEM); > - } > > - /* > - * Only scan the relevant parts containing pointers to other objects > - * to avoid false negatives. > - */ > - kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); > + /* > + * Only scan the relevant parts containing pointers to other objects > + * to avoid false negatives. > + */ > + kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); > + } > > retry: > if (addr == vend) { > -- > 2.39.2 > Looks good to me, feel free to add: Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
> + * Only scan the relevant parts containing pointers to other objects Please avoid the overly long line. The rest looks fine. > + * to avoid false negatives.
On Sun, Feb 04, 2024 at 10:41:13PM -0800, Christoph Hellwig wrote: > > + * Only scan the relevant parts containing pointers to other objects > > Please avoid the overly long line. > > The rest looks fine. > > > + * to avoid false negatives. > Thanks! -- Uladzislau Rezki
On Sun, Feb 04, 2024 at 07:44:55PM +0000, Lorenzo Stoakes wrote: > On Fri, Feb 02, 2024 at 08:06:28PM +0100, Uladzislau Rezki (Sony) wrote: > > Invoke a kmemleak_scan_area() function only for newly allocated > > objects to add a scan area within that object. There is no reason > > to add a same scan area(pointer to beginning or inside the object) > > several times. If a VA is obtained from the cache its scan area > > has already been associated. > > > > Fixes: 7db166b4aa0d ("mm: vmalloc: offload free_vmap_area_lock lock") > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > > --- > > mm/vmalloc.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > index 449f45b0e474..25a8df497255 100644 > > --- a/mm/vmalloc.c > > +++ b/mm/vmalloc.c > > @@ -1882,13 +1882,13 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, > > va = kmem_cache_alloc_node(vmap_area_cachep, gfp_mask, node); > > if (unlikely(!va)) > > return ERR_PTR(-ENOMEM); > > - } > > > > - /* > > - * Only scan the relevant parts containing pointers to other objects > > - * to avoid false negatives. > > - */ > > - kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); > > + /* > > + * Only scan the relevant parts containing pointers to other objects > > + * to avoid false negatives. > > + */ > > + kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); > > + } > > > > retry: > > if (addr == vend) { > > -- > > 2.39.2 > > > > Looks good to me, feel free to add: > > Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com> > Appreciate for review! -- Uladzislau Rezki
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 449f45b0e474..25a8df497255 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1882,13 +1882,13 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, va = kmem_cache_alloc_node(vmap_area_cachep, gfp_mask, node); if (unlikely(!va)) return ERR_PTR(-ENOMEM); - } - /* - * Only scan the relevant parts containing pointers to other objects - * to avoid false negatives. - */ - kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); + /* + * Only scan the relevant parts containing pointers to other objects + * to avoid false negatives. + */ + kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); + } retry: if (addr == vend) {