Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4067159imu; Fri, 30 Nov 2018 10:22:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/W5cJqH6Qc5yffwB4KieqhfHNpNhPNczsyC+YPCTX8QAYk+jGXBAmw/i/JQKcM9qNIQYhpD X-Received: by 2002:a63:314c:: with SMTP id x73mr5772136pgx.323.1543602155766; Fri, 30 Nov 2018 10:22:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543602155; cv=none; d=google.com; s=arc-20160816; b=AcRQ/9vw/80HSZMno/uGGieN3liSOmWFs3dxPtPmi4J2eeHgWMbWlWeQlrF3dTLoyR bjZPeyaB2OTRFN115bh6n/StdpdxsA/7R1naMiy/HW3kEs/2XS5+HobTDzbiokO4Zcbh LiCpX0Uu+Cj9pNyQv+Xa/MEZ0SLl2wTSjug4OwLCEL/B0k0CCBJp/z/ZoWREc6Tq+LG2 j56zcrUIK9k+SHeTxXl0r/9MLwgLmPoOXTiJCgqz1+1pOjUVKGWsfW0bElZMbOBqNGVi Df4XaawuobO3qG5/grvtJFgchR3XsJqHNPvcE4B5LJkpyhVe939iLprewhleQ/9sDNbT 1IEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XEWuCf+Hxi2CV7tqXLjn6OC2FZ9dmBl9fwY85ax/59w=; b=Bwj/BrPY5nxH5D1Ep5emJBNgFAtIzN9LkX52XiAb21nqN/0d46iVrJqXTJ/duW1JZY +0s+2OIN+cbCZ+hAaPRUZYwk8vfo54AW891QEyUfenTy0hq7szq1LxeQZUkKHyg+LCAg O7KNiJNim6hG3FUopCQfr16tcEnGodBCkfGMMDTRSnnTENbNAw9x1JWRxlt31SUg8bnF o/aGK+0MlB+N4DcAaN4QxdkU07rhMbn6bJ4yYmr/VwQZq9T6aJHVYdRwSdUSJ+W3yxpu OmgDiifi0fuaJNrkRVKCIsxxTxxECnkqVuFJUl56lqz+deP1GZ4No7H+cFZ606Y4qZ1h Jjdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si5498506pgr.569.2018.11.30.10.22.20; Fri, 30 Nov 2018 10:22:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726649AbeLAFaN (ORCPT + 99 others); Sat, 1 Dec 2018 00:30:13 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:38582 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbeLAFaN (ORCPT ); Sat, 1 Dec 2018 00:30:13 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1gSnOP-0000GL-3K; Fri, 30 Nov 2018 19:19:57 +0100 Date: Fri, 30 Nov 2018 19:19:57 +0100 From: Sebastian Andrzej Siewior To: He Zhe Cc: catalin.marinas@arm.com, tglx@linutronix.de, rostedt@goodmis.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Subject: Re: [PATCH v2] kmemleak: Turn kmemleak_lock to raw spinlock on RT Message-ID: <20181130181956.eewrlaabtceekzyu@linutronix.de> References: <1542877459-144382-1-git-send-email-zhe.he@windriver.com> <20181123095314.hervxkxtqoixovro@linutronix.de> <40a63aa5-edb6-4673-b4cc-1bc10e7b3953@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <40a63aa5-edb6-4673-b4cc-1bc10e7b3953@windriver.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-11-24 22:26:46 [+0800], He Zhe wrote: > On latest v4.19.1-rt3, both of the call traces can be reproduced with kmemleak > enabied. And none can be reproduced with kmemleak disabled. okay. So it needs attention. > On latest mainline tree, none can be reproduced no matter kmemleak is enabled > or disabled. > > I don't get why kfree from a preempt-disabled section should cause a warning > without kmemleak, since kfree can't sleep. it might. It will acquire a sleeping lock if it has go down to the memory allocator to actually give memory back. > If I understand correctly, the call trace above is caused by trying to schedule > after preemption is disabled, which cannot be reached in mainline kernel. So > we might need to turn to use raw lock to keep preemption disabled. The buddy-allocator runs with spin locks so it is okay on !RT. So you can use kfree() with disabled preemption or disabled interrupts. I don't think that we want to use raw-locks in the buddy-allocator. > >From what I reached above, this is RT-only and happens on v4.18 and v4.19. > > The call trace above is caused by grabbing kmemleak_lock and then getting > scheduled and then re-grabbing kmemleak_lock. Using raw lock can also solve > this problem. But this is a reader / writer lock. And if I understand the other part of the thread then it needs multiple readers. Couldn't we just get rid of that kfree() or move it somewhere else? I mean if the free() memory on CPU-down and allocate it again CPU-up then we could skip that, rigth? Just allocate it and don't free it because the CPU will likely get up again. > Thanks, > Zhe Sebastian