Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp331690ybb; Thu, 28 Mar 2019 03:31:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqweL0agKtE3VJ0EjdoSTvzNySbIElT0ssHvAXeICXfCEOmvFXhvpAvPB7K6dshL9FgynjEs X-Received: by 2002:a62:1690:: with SMTP id 138mr1567563pfw.28.1553769095372; Thu, 28 Mar 2019 03:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553769095; cv=none; d=google.com; s=arc-20160816; b=bY1ZZU91FincZZO5EsSG1b0RQ4OBOwZyumiD3DQsavUtUgV/aeyF1cJe8CcApfZpRW Kp0GleupUNvPfXmIVJSwv7mTJkzq7DKQLKQCEV87KOZpZxn1FZCvTiMWb+xTFUXeetY1 wSCMMM2aY6J51Mvn2pGuoSEZzbO/OZSSqZZgvN8JxTw9qMe5Bgoh76L3O52rwqb3h1C/ dMAYkGcuZS8Qd4BoI9IaCOStusvoAD1L03wMLcTR8vgLsfo8s4f7ONRXatHfiKCGKlsH uAO3zAHmAp8osbPXxfNGWXZx+J9+tR1WVzjeEThZfYz5qmeJZ5UgkfXH/u4oeD9bpShk hjRw== 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=0tN6E6/at6hVDKW/CRFmlOCD7fEuO3l9mz62aHzChc0=; b=vjQcAWTODuj8iL2RP0svJqEI1VkrR0mHaSJ5UIofFSy85dgST5wsClukOl0a3z7Ebq 2DOLyClAiCBnlHdShuq0ue8AM3kbiNoB9WetdVmSG6muX+8PsbJnvQ603oPxdbMONheu zv7z56D4dgUZimuqUcOF7CGzgbTQ3rkdm+A/1Zvbz47rdFo+Z9NXqUsFZweYgabQ83aM GRS/JUn79bN4XhXFZ885kPxF2kNq0zQXSvy0vwEH8cLKkH6LqidNgIJYFfs9jlBh0Ayw fwzImIs404P0vD67Y6xzDZ95riQawln4a0lqVx7i/qmCtY3LrUehLTpPPtInlSUeZnAs jUtA== 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 q7si14748616pls.259.2019.03.28.03.31.19; Thu, 28 Mar 2019 03:31:35 -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 S1726379AbfC1Ka2 (ORCPT + 99 others); Thu, 28 Mar 2019 06:30:28 -0400 Received: from foss.arm.com ([217.140.101.70]:42120 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbfC1Ka2 (ORCPT ); Thu, 28 Mar 2019 06:30:28 -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 16F7F15AB; Thu, 28 Mar 2019 03:30:26 -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 03B863F59C; Thu, 28 Mar 2019 03:30:23 -0700 (PDT) Date: Thu, 28 Mar 2019 10:30:21 +0000 From: Catalin Marinas To: Pekka Enberg Cc: Qian Cai , akpm@linux-foundation.org, cl@linux.com, mhocko@kernel.org, willy@infradead.org, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] kmemleak: survive in a low-memory situation Message-ID: <20190328103020.GA10283@arrakis.emea.arm.com> References: <20190327005948.24263-1-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Mar 28, 2019 at 08:05:31AM +0200, Pekka Enberg wrote: > On 27/03/2019 2.59, Qian Cai wrote: > > 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. > > Unfortunately I am not that brave soul, but I'm wondering what the > complication here is? It shouldn't be too hard to teach calculate_sizes() in > SLUB about a new SLAB_KMEMLEAK flag that reserves spaces for the metadata. I don't think it's the calculate_sizes() that's the hard part. The way kmemleak is designed assumes that the metadata has a longer lifespan than the slab object it is tracking (and refcounted via get_object/put_object()). We'd have to replace some of the rcu_read_(un)lock() regions with a full kmemleak_lock together with a few more tweaks to allow the release of kmemleak_lock during memory scanning (which can take minutes; so it needs to be safe w.r.t. metadata freeing, currently relying on a deferred RCU freeing). Anyway, I think it is possible, just not straight forward. -- Catalin