From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756086AbeDZM4m (ORCPT ); Thu, 26 Apr 2018 08:56:42 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53270 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755959AbeDZM4j (ORCPT ); Thu, 26 Apr 2018 08:56:39 -0400 Date: Thu, 26 Apr 2018 13:56:35 +0100 From: Catalin Marinas To: Chunyu Hu Cc: Michal Hocko , Chunyu Hu , Dmitry Vyukov , LKML , Linux-MM Subject: Re: [RFC] mm: kmemleak: replace __GFP_NOFAIL to GFP_NOWAIT in gfp_kmemleak_mask Message-ID: <20180426125634.uybpbbk5puee7fsg@armageddon.cambridge.arm.com> References: <1524243513-29118-1-git-send-email-chuhu@redhat.com> <20180420175023.3c4okuayrcul2bom@armageddon.cambridge.arm.com> <20180422125141.GF17484@dhcp22.suse.cz> <20180424132057.GE17484@dhcp22.suse.cz> <850575801.19606468.1524588530119.JavaMail.zimbra@redhat.com> <20180424170239.GP17484@dhcp22.suse.cz> <732114897.20075296.1524745398991.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <732114897.20075296.1524745398991.JavaMail.zimbra@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 26, 2018 at 08:23:19AM -0400, Chunyu Hu wrote: > kmemleak is using kmem_cache to record every pointers returned from kernel mem > allocation activities such as kmem_cache_alloc(). every time an object from > slab allocator is returned, a following new kmemleak object is allocated. > > And when a slab object is freed, then the kmemleak object which contains > the ptr will also be freed. > > and kmemleak scan thread will run in period to scan the kernel data, stack, > and per cpu areas to check that every pointers recorded by kmemleak has at least > one reference in those areas beside the one recorded by kmemleak. If there > is no place in the memory acreas recording the ptr, then it's possible a leak. > > so once a kmemleak object allocation failed, it has to disable itself, otherwise > it would lose track of some object pointers, and become less meaningful to > continue record and scan the kernel memory for the pointers. So disable > it forever. so this is why kmemleak can't tolerate a slab alloc fail (from fault injection) > > @Catalin, > > Is this right? If something not so correct or precise, please correct me. That's a good description, thanks. > I'm thinking about, is it possible that make kmemleak don't disable itself > when fail_page_alloc is enabled? I can't think clearly what would happen > if several memory allocation missed by kmelkeak trace, what's the bad result? Take for example a long linked list. If kmemleak doesn't track an object in such list (because the metadata allocation failed), such list_head is never scanned and the subsequent objects in the list (pointed at by 'next') will be reported as leaks. Kmemleak pretty much becomes unusable with a high number of false positives. -- Catalin