Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4423719img; Tue, 26 Mar 2019 09:07:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtN/wocMi3H+n7OzaGR+Px/9tZuMcuFHjUOdavvVK2hwYGEoXwLlGn3EwUY6E3X73RfPNH X-Received: by 2002:a62:e911:: with SMTP id j17mr30449051pfh.107.1553616463640; Tue, 26 Mar 2019 09:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553616463; cv=none; d=google.com; s=arc-20160816; b=Pq1Nl22jU7kJdQsfEDWlnNX2m1tfAzRfeWZCnGCGSOJj/TUePVMxl5MkQ0wxDaEemI 428EJIixh1jpQYsqLBV6ReeQG24hibNslPmOfxJY4sOSrjdtGb9Yrin1qpx4iPclm+56 umm/6Zh13JhzIgsqCgrxjXa/qYQ4PlDxeULE6SZ5flobVdbJsJeLwNNOKumgPYAjhsBg G1T3/axE0nCT6OUL09DPmsqGbSDtifdSH6L0I2YFSlMuoHdxMUPYudkSFad8crN1tlaO mWBcszdwZxb0Y6vSknL+gj08EGsdcBAM3xi+nZpyESpsfhxpZFO46seKBNRQpuP8LDaV UFTQ== 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=gC5njTJokzuYnLO6T1L2PGEt+a8ve6SLWhGK1aYGBbA=; b=08t4I5axx08fAVhNTxDlULSAouv7SQhpSWzhxwoSASURmca54n33p90PH9eER3DOXG VygUXcX6w9qqMpnMMOd6zkAeiJg0Z92ucj33Pj/j9AemulMibkEcTyvVfqsBBgsUx3w2 XTgoYZ+7fDJSkqt6EFqACGRamxWKq1Ewqbhw7TNLf8/q2bZ5k0ZPTyS9xMXvCfzebCw0 5TkMuj4wehILr5KEDr+qk7W5gK1+LxTPBCmDqfLBK4uxsnwbd1T1zKNO6uSw16SygXkA u6cgFVNFO//u5RFETuVIeKl6Jx/Odpv3FVcYotkJ8dgZoUfPgYVn3Z+SD6oMs9l/5X4a rcMg== 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 r4si11142466pgh.171.2019.03.26.09.07.27; Tue, 26 Mar 2019 09:07:43 -0700 (PDT) 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 S1731653AbfCZQGZ (ORCPT + 99 others); Tue, 26 Mar 2019 12:06:25 -0400 Received: from foss.arm.com ([217.140.101.70]:39140 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbfCZQGZ (ORCPT ); Tue, 26 Mar 2019 12:06:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 876E51596; Tue, 26 Mar 2019 09:06:22 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BA4B33F614; Tue, 26 Mar 2019 09:06:20 -0700 (PDT) Date: Tue, 26 Mar 2019 16:06:18 +0000 From: Catalin Marinas To: Qian Cai Cc: akpm@linux-foundation.org, mhocko@kernel.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] kmemleaak: survive in a low-memory situation Message-ID: <20190326160617.GG33308@arrakis.emea.arm.com> References: <20190326154338.20594-1-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190326154338.20594-1-cai@lca.pw> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 26, 2019 at 11:43:38AM -0400, Qian Cai wrote: > Kmemleak could quickly fail to allocate an object structure and then > disable itself in a low-memory situation. For example, running a mmap() > workload triggering swapping and OOM. This is especially problematic for > running things like LTP testsuite where one OOM test case would disable > the whole kmemleak and render the rest of test cases without kmemleak > watching for leaking. > > Kmemleak allocation could fail even though the tracked memory is > succeeded. Hence, it could still try to start a direct reclaim if it is > not executed in an atomic context (spinlock, irq-handler etc), or a > high-priority allocation in an atomic context as a last-ditch effort. > Since kmemleak is a debug feature, it is unlikely to be used in > production that memory resources is scarce where direct reclaim or > high-priority atomic allocations should not be granted lightly. > > Unless there is a brave soul to reimplement the kmemleak to embed it's > metadata into the tracked memory itself in a foreseeable future, this > provides a good balance between enabling kmemleak in a low-memory > situation and not introducing too much hackiness into the existing > code for now. Embedding the metadata would help with the slab allocations (though not with vmalloc) but it comes with its own potential issues. There are some bits of kmemleak that rely on deferred freeing of metadata for RCU traversal, so this wouldn't go well with embedding it. I wonder whether we'd be better off to replace the metadata allocator with gen_pool. This way we'd also get rid of early logging/replaying of the memory allocations since we can populate the gen_pool early with a static buffer. -- Catalin