From mboxrd@z Thu Jan 1 00:00:00 1970 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 40262C433FE for ; Tue, 1 Nov 2022 09:21:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DB366B0072; Tue, 1 Nov 2022 05:21:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68B4D6B0073; Tue, 1 Nov 2022 05:21:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52B026B0074; Tue, 1 Nov 2022 05:21:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4260A6B0072 for ; Tue, 1 Nov 2022 05:21:35 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 07E44809B7 for ; Tue, 1 Nov 2022 09:21:35 +0000 (UTC) X-FDA: 80084330550.08.39BD1F0 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by imf14.hostedemail.com (Postfix) with ESMTP id 1A4A610000C for ; Tue, 1 Nov 2022 09:21:32 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id E8A4A32006F5; Tue, 1 Nov 2022 05:21:29 -0400 (EDT) Received: from imap46 ([10.202.2.96]) by compute5.internal (MEProxy); Tue, 01 Nov 2022 05:21:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com.au; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1667294489; x=1667380889; bh=Dm Xcbh9DqaxTidfPEVRhGG+9ZolCRC1Se1Rd95/vqz4=; b=bmvYswt1B92Yx+FDX7 KL4ZPZ9jIPcqU6eco2cO4QR6U4FlgIIRCKCqm6sECof4qGhQh3+eEaL1gpcf4rir rBk0JncdKtJqeRBglxBUM4xku0NsHymB6uNOknsHMMTGQ5VpSv9aZc9FtSaws5sB r0i+BdDjQMGSPhJHU1AdO0UkDHZ75YORfxo6YtikYIaf3FvlfcT71H9BwgbxqKs6 TiHPyLthYSqh4VNFMv8pTO2UJKQFLBPQMc9uy8SovzYLKUC6GQy6xEi1p9gYVDdK 70+7lKiJu5u9DZGJKh8dEDJH47nMtrAjrS6xBDH6Pf3jVnMKUyQaRUQ90IbURjlP 2zNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1667294489; x=1667380889; bh=DmXcbh9DqaxTidfPEVRhGG+9ZolC RC1Se1Rd95/vqz4=; b=NWQ36jlqzp1+xxohT0ZSzXSPkWWA/eeyBpQtz29TEitj B2zEw4SWePIpohw4WCV0SGREYDHKe9AkUgJrv6tUIAQkBRf5SRpF2CMS6v6pnaMJ i7kK8W4ekPTPuixPnEAFAox5ZbLjIVzukyGPWZEbOocOOrTBSWZbINn8oHUhD/rR SSFZllolzcpAalF/ncFf8iiSuYVHnpG4n087do3IL1fYwFwGTf3nxNKLR76DD3Iz pLtayC80y39K4dV7Ma0XWSKAG0polbUqv/CzEIxox1uyIADEfJmpCxKRtx9Vhbck 992rWY44IjHLWJr7ge4Q3WFOvBCmPOKUy8DlqtB9pA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrudehgddtvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdflohhh nhcuvfhhohhmshhonhdfuceolhhishhtshesjhhohhhnthhhohhmshhonhdrfhgrshhtmh grihhlrdgtohhmrdgruheqnecuggftrfgrthhtvghrnhepjeejfeeilefgfedtkeekfeek ffegleetlefhheekleeggfdttdevveduheettefgnecuffhomhgrihhnpehkvghrnhgvlh drohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehlihhsthhssehjohhhnhhthhhomhhsohhnrdhfrghsthhmrghilhdrtghomhdrrghu X-ME-Proxy: Feedback-ID: ia7894244:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B42052A20080; Tue, 1 Nov 2022 05:21:27 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1087-g968661d8e1-fm-20221021.001-g968661d8 Mime-Version: 1.0 Message-Id: <53b53476-bb1e-402e-9f65-fd7f0ecf94c2@app.fastmail.com> In-Reply-To: References: <20220913065423.520159-1-feng.tang@intel.com> <20220913065423.520159-2-feng.tang@intel.com> <9b71ae3e-7f53-4c9e-90c4-79d3d649f94c@app.fastmail.com> Date: Tue, 01 Nov 2022 09:20:21 +0000 From: "John Thomson" To: "Feng Tang" Cc: "Vlastimil Babka" , "Andrew Morton" , "Christoph Lameter" , "Pekka Enberg" , "David Rientjes" , "Joonsoo Kim" , "Roman Gushchin" , "Hyeonggon Yoo" <42.hyeyoo@gmail.com>, "Dmitry Vyukov" , "Jonathan Corbet" , "Andrey Konovalov" , "Hansen, Dave" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "kasan-dev@googlegroups.com" , "Robin Murphy" , "John Garry" , "Kefeng Wang" , "Thomas Bogendoerfer" , linux-mips@vger.kernel.org Subject: Re: [PATCH v6 1/4] mm/slub: enable debugging memory wasting of kmalloc Content-Type: text/plain ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=fastmail.com.au header.s=fm3 header.b=bmvYswt1; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=NWQ36jlq; spf=pass (imf14.hostedemail.com: domain of lists@johnthomson.fastmail.com.au designates 64.147.123.24 as permitted sender) smtp.mailfrom=lists@johnthomson.fastmail.com.au; dmarc=pass (policy=none) header.from=fastmail.com.au ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667294493; a=rsa-sha256; cv=none; b=IVZqkcdyR2qChrK1aMLpN2E5OwovvapaiDxXLA22G0Elhcm4AmS/M75lHtPZvSg2+MKb9b 2O4foy+7EXP62ndgcd5qNmT5VrdfhTaTjDCI/QUUCpX12/U2BwJp0AoBUXXh1//HiMy8y2 FcGSlhSpw5JlCGHu7IhwGwQo17kQA1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667294493; 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=DmXcbh9DqaxTidfPEVRhGG+9ZolCRC1Se1Rd95/vqz4=; b=BKD/W/UEr6qYHNsyruYMurhCTTOCTEofm45VHMqMdBFSA0CCocakYZAXDeLPDXWynofTxs BSQF2WoqID7WCVESg0MuQp9Z6clCR6q7aQD0/6ijk6ZgS+08KP364i9dfl1omL7QnDKx4P 6AXdkujMCde9WKaZoYrvzAxF/LbZb9Y= X-Rspam-User: X-Rspamd-Queue-Id: 1A4A610000C Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=fastmail.com.au header.s=fm3 header.b=bmvYswt1; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=NWQ36jlq; spf=pass (imf14.hostedemail.com: domain of lists@johnthomson.fastmail.com.au designates 64.147.123.24 as permitted sender) smtp.mailfrom=lists@johnthomson.fastmail.com.au; dmarc=pass (policy=none) header.from=fastmail.com.au X-Stat-Signature: hqkmciiymizkh4jrwzoxh6h8ga7hpqmz X-Rspamd-Server: rspam10 X-HE-Tag: 1667294492-292189 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 1 Nov 2022, at 07:57, Feng Tang wrote: > Hi Thomson, > > Thanks for testing! > > + mips maintainer and mail list. The original report is here > > https://lore.kernel.org/lkml/becf2ac3-2a90-4f3a-96d9-a70f67c66e4a@app.fastmail.com/ I am guessing my issue comes from __kmem_cache_alloc_lru accessing s->object_size when (kmem_cache) s is NULL? If that is the case, this change is not to blame, it only exposes the issue? I get the following dmesg (note very early NULL kmem_cache) with the below change atop v6.1-rc3: transfer started ......................................... transfer ok, time=2.02s setting up elf image... OK jumping to kernel code zimage at: 80B842A0 810B4EFC Uncompressing Linux at load address 80001000 Copy device tree to address 80B80EE0 Now, booting the kernel... [ 0.000000] Linux version 6.1.0-rc3+ (john@john) (mipsel-buildroot-linux-gnu-gcc.br_real (Buildroot 2021.11-4428-g6b6741b) 12.2.0, GNU ld (GNU Binutils) 2.39) #61 SMP Tue Nov 1 18:04:13 AEST 2022 [ 0.000000] slub: kmem_cache_alloc called with kmem_cache: 0x0 [ 0.000000] slub: __kmem_cache_alloc_lru called with kmem_cache: 0x0 [ 0.000000] SoC Type: MediaTek MT7621 ver:1 eco:3 [ 0.000000] printk: bootconsole [early0] enabled [ 0.000000] CPU0 revision is: 0001992f (MIPS 1004Kc) [ 0.000000] MIPS: machine is MikroTik RouterBOARD 760iGS normal boot diff --git a/mm/slub.c b/mm/slub.c index 157527d7101b..10fcdf2520d2 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3410,7 +3410,13 @@ static __always_inline void *__kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, gfp_t gfpflags) { - void *ret = slab_alloc(s, lru, gfpflags, _RET_IP_, s->object_size); + void *ret; + if (IS_ERR_OR_NULL(s)) { + pr_warn("slub: __kmem_cache_alloc_lru called with kmem_cache: %pSR\n", s); + ret = slab_alloc(s, lru, gfpflags, _RET_IP_, 0); + } else { + ret = slab_alloc(s, lru, gfpflags, _RET_IP_, s->object_size); + } trace_kmem_cache_alloc(_RET_IP_, ret, s, gfpflags, NUMA_NO_NODE); @@ -3419,6 +3425,8 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) { + if (IS_ERR_OR_NULL(s)) + pr_warn("slub: kmem_cache_alloc called with kmem_cache: %pSR\n", s); return __kmem_cache_alloc_lru(s, NULL, gfpflags); } EXPORT_SYMBOL(kmem_cache_alloc); @@ -3426,6 +3434,8 @@ EXPORT_SYMBOL(kmem_cache_alloc); void *kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, gfp_t gfpflags) { + if (IS_ERR_OR_NULL(s)) + pr_warn("slub: __kmem_cache_alloc_lru called with kmem_cache: %pSR\n", s); return __kmem_cache_alloc_lru(s, lru, gfpflags); } EXPORT_SYMBOL(kmem_cache_alloc_lru); Any hints on where kmem_cache_alloc would be being called from this early? I will start looking from /init/main.c around pr_notice("%s", linux_banner); Thank you for your help. Let me know if you want me to stop replying to this mm/slub debug memory wasting email, and take this to a new email? Cheers, -- John Thomson