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 D36E0C433EF for ; Fri, 3 Dec 2021 00:52:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8D0E6B0072; Thu, 2 Dec 2021 19:52:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D3D506B0074; Thu, 2 Dec 2021 19:52:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C043E6B0075; Thu, 2 Dec 2021 19:52:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id B22F36B0072 for ; Thu, 2 Dec 2021 19:52:41 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 68E6189B57 for ; Fri, 3 Dec 2021 00:52:31 +0000 (UTC) X-FDA: 78874657302.09.96F476A Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf12.hostedemail.com (Postfix) with ESMTP id 9AC6C10000A5 for ; Fri, 3 Dec 2021 00:52:31 +0000 (UTC) Received: by mail-pg1-f181.google.com with SMTP id r5so1408647pgi.6 for ; Thu, 02 Dec 2021 16:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KcgckVJBk609C9n8WlYPxKWxBCCyIgqINt/uZGi6A0Y=; b=Ctf7ofl9Xke/PvNfOa+Vrw+j8ZBmzqUrFn63JewI2pdb1XRMsZgcYJ6ssqVhQpeDjA ya/eT9D/t9b86F/AArvhA/u4vb7Q466qgo9KzGmBFPZijZkkoSob/z+47kRcGLqgoLcX bsKy2XDc+XW2Z3hJyPDbt5ekMsag8vEQ2CepLHEGWHzbT4FUP8ejDg9HntELO6U/kHXv 0lfZVQR7cTvYiPYD9S0BPTPNA7HKN4I5EniGd53Riw/4BkWX0Rzro4VxzMSJ2yNh1zWV Ss04cFrELxmFNzr+xgR2eQO2siyrMfdD3g7WfN8Jk6hkDnUt2W+67yQTSa55mAdVQ+Wq eSag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KcgckVJBk609C9n8WlYPxKWxBCCyIgqINt/uZGi6A0Y=; b=oaxNHG7C3g4LJB8KmHY0FSpQQYjk8L0pKp8jEgeL342msCsI9ZqBLcHza5FmViMkss lQvOs2F1D/Gnw8osVb8qh08FnR3hGdZBv1ruSakb9Pl+AXAoVfqrjJSPdfThxXEQfmoZ IkXudTzSDKhH//qiYtcsxxf8EXiRfFi9dTVdhN9IdjFxfwcSBuDAPMA63Y9R8hrX08nD pVnlzievgLzYsSb7ogUythfg0qP0FuEv07f/ZjzWCIy/pW8o/Oj4UDb03ve18cBbiB/0 NKsHVIoliJmKMMjIuO5KqF4B9J4X6l13rJFgoB3b+uKuYqcmSSxYMqnwAAze4BLc7Ks9 TqNw== X-Gm-Message-State: AOAM532Ce4U0xDfE3A7DoirHaBF/TKMn5Zyb1tUyrD4BIgjby4mb7JHx e5+B2hS6vGc/PKZQnfu0jek= X-Google-Smtp-Source: ABdhPJy0wAKaq2tyZW6eEKVEZ01mPalVC9neiDt4H5evhXCCzzA5axCTHMxBIQfQZL4+VtxXQMlS3g== X-Received: by 2002:a05:6a00:15ca:b0:49f:d22b:afff with SMTP id o10-20020a056a0015ca00b0049fd22bafffmr15996509pfu.35.1638492749937; Thu, 02 Dec 2021 16:52:29 -0800 (PST) Received: from localhost ([103.99.179.247]) by smtp.gmail.com with ESMTPSA id h26sm652480pgm.68.2021.12.02.16.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 16:52:29 -0800 (PST) Date: Fri, 3 Dec 2021 08:52:24 +0800 From: Calvin Zhang To: Catalin Marinas Cc: Andrew Morton , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Subject: Re: [PATCH] mm: kmemleak: Ignore kmemleak scanning on CMA regions Message-ID: References: <20211126024711.54937-1-calvinzhang.cool@gmail.com> <20211127160718.54e82aa93c977a367404a9e3@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9AC6C10000A5 X-Stat-Signature: hbx3wha5ck9kypjmnar5hcua4t7u9cnz Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Ctf7ofl9; spf=pass (imf12.hostedemail.com: domain of calvinzhang.cool@gmail.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=calvinzhang.cool@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638492751-530639 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 Thu, Dec 02, 2021 at 06:11:12PM +0000, Catalin Marinas wrote: >On Sun, Nov 28, 2021 at 09:50:53AM +0800, Calvin Zhang wrote: >> On Sat, Nov 27, 2021 at 04:07:18PM -0800, Andrew Morton wrote: >> >On Fri, 26 Nov 2021 10:47:11 +0800 Calvin Zhang wrote: >> >> Just like this: >> >> commit 620951e27457 ("mm/cma: make kmemleak ignore CMA regions"). >> >> >> >> Add kmemleak_ignore_phys() for CMA created from of reserved node. >[...] >> >The 620951e27457 changelog says "Without this, the kernel crashes...". >> >Does your patch also fix a crash? If so under what circumstances and >> >should we backport this fix into -stable kernels? >> >> No crash occurred. 620951e27457 avoids crashes caused by accessing >> highmem and it was fixed later. Now kmemleak_alloc_phys() and >> kmemleak_ignore_phys() skip highmem. This patch is based on the >> point that CMA regions don't contain pointers to other kmemleak >> objects, and ignores CMA regions from reserved memory as what >> 620951e27457 did. > >Note that kmemleak_ignore() only works if there was a prior >kmemleak_alloc() on that address range. With the previous commit we get >this via the memblock_alloc_range() but I fail to see one on the >rmem_cma_setup() path. rmem is from memblock_reserve() or early_init_dt_alloc_reserved_memory_arch() kmemleak_alloc() is not called in the first case. And It's bad to add one. I think all the reserved regions should be allocated from memblock without kmemleak_alloc() and let rmem handler choose to add it as kmemleak object by kmemleak_alloc(). Because MEMBLOCK_ALLOC_NOLEAKTRACE conflicts with range parameter in memlbock_alloc_* series, all reserved regions and default CMA region are allocated with kmemleak_alloc(). I think it's better to add memblock_alloc_* series a spearate flag paramter (like "NOLEAKTRACE") instead of encoding MEMBLOCK_ALLOC_NOLEAKTRACE in `end` parameter. -- Calvin