Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4374044pxu; Wed, 9 Dec 2020 15:49:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdtoy8xN615mxQIajufF7lhYYiCW9eSyA0/w++l7PhHLsje2UuuLd/ipSv6jEA8itUy8QS X-Received: by 2002:a50:d4cd:: with SMTP id e13mr4224678edj.117.1607557749902; Wed, 09 Dec 2020 15:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607557749; cv=none; d=google.com; s=arc-20160816; b=WsKiKthF2watV6sRSL1qoAfuuolGZz2+2cTaHjSgyY1NN2lnZHGJgsVxrgGBng1wvh x5N3t7KGfnWQZfSnW1G1hcj2UMLym8imG1V9gNQ3rRmrcaEfHsW4YUAb1j3y28nSttYj Be280jkqrVIfynasysat6nzHKhK/aHJwMv3f3Il0cvHgWB0/lsgBqV4baCZTJu2dAT3p d93LyK1SFuaFsnz7w7qwRV7Hu2bPE09MW6HxyvZOCDy490x8eqzsM3fMfecmfD6dC99k GWNWfUCP6hV4h+QhOuP3PnxQLRGQ/mDm91GXJFlpCdqpQ3a8doPb6LecL3SaKlAHaF8e h2zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=jH8OAw8LOFPt4TBxe6UIavXjQgmgainyU9Gu6QLTrig=; b=kYHB8ASTHqdqN6tvMwTEOqgQPomUSA2fmVWgCkC7iWA/fvdJbf0xw7u8o2p5AJRQeN cCv8BMzhs6BD+p3obKY6FKBIpGvZdencwq245EA3jW5/NSAwiP5trEfcOesIYJOFcfGC X5NmDUFl74Yv7DRozyQNFLwPkjc5Lq8O/okLwBbwFf0YmddsR49g+YBmH+OtxYHmjMtt Miwbfad3eFmUZn2yqZQmNVe8qUnVwhb0QwfB3vDKYLJXmhchrYR/8kZ+iWq886Ka33+B jDfRJ0JVbix3NufwXPgNeKMfI+4p51sMqfEsh2NGtDHEIkAgjktTOt71Gq+axBhuX8aw PXBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hb8Lr9Yx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si1664898edx.591.2020.12.09.15.48.47; Wed, 09 Dec 2020 15:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hb8Lr9Yx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387630AbgLIThZ (ORCPT + 99 others); Wed, 9 Dec 2020 14:37:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729787AbgLIThW (ORCPT ); Wed, 9 Dec 2020 14:37:22 -0500 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D7BFC0613CF; Wed, 9 Dec 2020 11:36:41 -0800 (PST) Received: by mail-lf1-x141.google.com with SMTP id l11so4757997lfg.0; Wed, 09 Dec 2020 11:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=jH8OAw8LOFPt4TBxe6UIavXjQgmgainyU9Gu6QLTrig=; b=hb8Lr9Yx4FJ/a+SiBXO8oYZ1m2D0teBFqYcwE5wF9/4sMBUlqxKy4aVmU4JW4wvCNx /MyFbrAFFPIZd5rr10DcE2+t+9pfz1EXvllvsTmgItnvzRK4LSavxLSWD55uR0nENhDk x2Pfu+SoMW+pk+aIX8yEmeu5d2s7urXul+KiXDU2oJmZ7sMbHi8sxDhFeaQoglmAq0Vz W1+gGJnKy4g+qf8bnnpkal1nlAoj8lmUtwaJmz23o611lvCjw5zNyjLafZXRgPyKv2qs 1VqyDPS/n/+dwDZwuGkHnxuBMUPOdckWlR1/4QqA/Ndzw/0KQOOC15Ydo43sfZbmsEYA +efg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=jH8OAw8LOFPt4TBxe6UIavXjQgmgainyU9Gu6QLTrig=; b=YjEdSclnfEKAZCwWXhvKajpN0JvF74Gd7KHQhzUHvoz0UyTuis3CuyQWaSVNI3w4Uw y71C5zXyzmDiBRYRu6jcuytjKFNP/vq4A4gT5ZcaRdao9HdF0t3pLVW6JzphGxHMGx+9 gWJG9eJmBipITta44ILdCiLiAGQ6I8Ew8cBkC6+HIy6V/SFelyc0tO2AbBx88sAmR3Un ghHCtzNnJvJF/b0E1kK/CxP8asId+t71HZU5IObuVv0nZ6eEFZ1SQOFG+Ue3knhv/l6G r3oWKcwS0VBPQgASxCcJGHp8HdQ/oxwvTi/F3Gl/oH4WE4CoO2sP4Aq/IjHRfEFsS5fd brhQ== X-Gm-Message-State: AOAM533NXTctC71yD+UPFhTzaz/UGL5evL4Zx+yeZl4nixZ0KBihYyNM 654MdbH3hvrI6HsBEEoPXhs= X-Received: by 2002:ac2:5f63:: with SMTP id c3mr1355372lfc.451.1607542600079; Wed, 09 Dec 2020 11:36:40 -0800 (PST) Received: from pc638.lan (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id u11sm267162lfq.142.2020.12.09.11.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 11:36:39 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Wed, 9 Dec 2020 20:36:37 +0100 To: paulmck@kernel.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, iamjoonsoo.kim@lge.com, andrii@kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 sl-b 3/5] mm: Make mem_dump_obj() handle vmalloc() memory Message-ID: <20201209193637.GA5757@pc638.lan> References: <20201209011124.GA31164@paulmck-ThinkPad-P72> <20201209011303.32737-3-paulmck@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201209011303.32737-3-paulmck@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 08, 2020 at 05:13:01PM -0800, paulmck@kernel.org wrote: > From: "Paul E. McKenney" > > This commit adds vmalloc() support to mem_dump_obj(). Note that the > vmalloc_dump_obj() function combines the checking and dumping, in > contrast with the split between kmem_valid_obj() and kmem_dump_obj(). > The reason for the difference is that the checking in the vmalloc() > case involves acquiring a global lock, and redundant acquisitions of > global locks should be avoided, even on not-so-fast paths. > > Note that this change causes on-stack variables to be reported as > vmalloc() storage from kernel_clone() or similar, depending on the degree > of inlining that your compiler does. This is likely more helpful than > the earlier "non-paged (local) memory". > > Cc: Andrew Morton > Cc: Joonsoo Kim > Cc: > Reported-by: Andrii Nakryiko > Signed-off-by: Paul E. McKenney > --- > include/linux/vmalloc.h | 6 ++++++ > mm/util.c | 12 +++++++----- > mm/vmalloc.c | 12 ++++++++++++ > 3 files changed, 25 insertions(+), 5 deletions(-) > > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h > index 938eaf9..c89c2be 100644 > --- a/include/linux/vmalloc.h > +++ b/include/linux/vmalloc.h > @@ -248,4 +248,10 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) > int register_vmap_purge_notifier(struct notifier_block *nb); > int unregister_vmap_purge_notifier(struct notifier_block *nb); > > +#ifdef CONFIG_MMU > +bool vmalloc_dump_obj(void *object); > +#else > +static inline bool vmalloc_dump_obj(void *object) { return false; } > +#endif > + > #endif /* _LINUX_VMALLOC_H */ > diff --git a/mm/util.c b/mm/util.c > index 8c2449f..ee99a0a 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -984,6 +984,12 @@ int __weak memcmp_pages(struct page *page1, struct page *page2) > */ > void mem_dump_obj(void *object) > { > + if (kmem_valid_obj(object)) { > + kmem_dump_obj(object); > + return; > + } > + if (vmalloc_dump_obj(object)) > + return; > if (!virt_addr_valid(object)) { > if (object == NULL) > pr_cont(" NULL pointer.\n"); > @@ -993,10 +999,6 @@ void mem_dump_obj(void *object) > pr_cont(" non-paged (local) memory.\n"); > return; > } > - if (kmem_valid_obj(object)) { > - kmem_dump_obj(object); > - return; > - } > - pr_cont(" non-slab memory.\n"); > + pr_cont(" non-slab/vmalloc memory.\n"); > } > EXPORT_SYMBOL_GPL(mem_dump_obj); > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 6ae491a..7421719 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -3431,6 +3431,18 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) > } > #endif /* CONFIG_SMP */ > > +bool vmalloc_dump_obj(void *object) > +{ > + struct vm_struct *vm; > + void *objp = (void *)PAGE_ALIGN((unsigned long)object); > Paul, vmalloced addresses are already aligned to PAGE_SIZE, so that one is odd. -- Vlad Rezki