Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6863533rdb; Fri, 15 Dec 2023 10:12:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdn56wI2s6rbTWJZu1V0xjldBlAPJV1ZV3t0UEV66ftxRo/haIu+LjvSEqIMRoiviwNglk X-Received: by 2002:a05:6a21:3281:b0:18b:985e:8035 with SMTP id yt1-20020a056a21328100b0018b985e8035mr7892862pzb.12.1702663825943; Fri, 15 Dec 2023 10:10:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702663825; cv=none; d=google.com; s=arc-20160816; b=vOGRpvOeejZCT+vNrtBLxbkKytxx05kHWJ1K083hiA59WZdpYZdZAGOmEEl9FEcAdY XSBcf7hTxPwL6cOVtQCI9Q6X6nLtlzNOEylY9T5I4dFO3Av01Cca9mRQRQurfjx7osPA zbHhz42/rdtzzAHhudsgMi4bp9DAYNk1FESzH51tozQBh6xTWMYKd0Vval4vPyDb6tZW bFR9vvkl9haOJi6PXeqKSEznkhuUoi7FJ7tG2OGC+mRadEKilSN/DOpiL95GVKdO+Ave oRT9b0qKhZgIZsQRe05dqtwUcpCryQIlAry3+Zse+YHTmhlPju4gAb9bA1uifQU7HH+C PM5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=A74NBgisHkNtOA8ksWBRs+zqXQcddPtfJItFsqx1RUk=; fh=16TNXBIzkElzhiRnsUs/LMahDFqnM+BAWQdn/tOdxR8=; b=h5EEK7jg98pjeWF/c//Vp/QULvpiNLlDw11mGzk9dP628VNiIGcNUJV8T05S5wLHVv L93M0xnGqfxeR3+dchp5WxdqPhzKsGrqt1mI1RQl+lVmzqYy2KjszXqpp8MAqoA4qMhr PUFcLmSjnvJ6ixy5L4IfH+hAm7UffRvec9DYDDCA3l81X9vhq5Yel6gdG28oMJXcSc6A TOJ95E1rClvaPXJxTdsh9Bo6Q7T4dQEulP5LEzOAvetI97d7RLLayXZAmqW0WbBRRg6K SMfrfbXkC2WWAI+DGqgFj3weo32ZXvItN5s8o6cF+3/NMeEi2IBJT7bnIgXa8WnfmAC9 /JBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QDCXAPPO; spf=pass (google.com: domain of linux-kernel+bounces-1505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1505-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o21-20020a634e55000000b005c693ea6618si13552914pgl.523.2023.12.15.10.10.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 10:10:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QDCXAPPO; spf=pass (google.com: domain of linux-kernel+bounces-1505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1505-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 91C832848D3 for ; Fri, 15 Dec 2023 18:10:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7EE43FB0B; Fri, 15 Dec 2023 18:10:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QDCXAPPO" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AA5C30129 for ; Fri, 15 Dec 2023 18:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702663810; x=1734199810; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=chXsHALesc7fMigjpB8mkMQzFl4hKSDNazDZ6RjWiSc=; b=QDCXAPPOhxoLfJXYwmT1wu0HFjMV6iwxnQlIeCY/ILlmySP6ghxawD2u i77TLUvbZgg95AEERStUPVDRlkxeiwfIDoL+Flyo5JZoVzsHJ3dU1tISk Tjmqfk0IimLw5hPwD+w81cwV9J3LoC6F3LpTO5C2K/tpVAQDZFlPU142+ 5RZSPVSc+GeS83v8F35Z4kDDBNyXe/jVi5lS36Yh65uxAaQrW6euxSkWv 34erJcgiMEp3X4i0x+fDPwvtxhQd3nub/dN9LSdjo7pns97rp6kXDeB53 R3QJk1QFcosMtTgQpyg4d1ERI436zNGYit65GDYj3GIOJa7C8XxCeKq7M w==; X-IronPort-AV: E=McAfee;i="6600,9927,10925"; a="426439108" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="426439108" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 10:10:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10925"; a="803790500" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="803790500" Received: from jwaxmons-hp.amr.corp.intel.com (HELO [10.212.150.221]) ([10.212.150.221]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 10:10:09 -0800 Message-ID: <99ce13b6-600d-411e-9dab-97a8ed166deb@intel.com> Date: Fri, 15 Dec 2023 10:10:08 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: mm/DAMON: Profiling enhancements for DAMON Content-Language: en-US To: Aravinda Prasad , damon@lists.linux.dev, linux-mm@kvack.org, sj@kernel.org, linux-kernel@vger.kernel.org Cc: s2322819@ed.ac.uk, sandeep4.kumar@intel.com, ying.huang@intel.com, dan.j.williams@intel.com, sreenivas.subramoney@intel.com, antti.kervinen@intel.com, alexander.kanevskiy@intel.com, Alan Nair References: <20231215074619.173787-1-aravinda.prasad@intel.com> From: Dave Hansen Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2hTkyKUSNkduyoZ9F5twiBhxPJwPtn/wnch6n5RsoXsb ygOEDxLEsSk/7eyFycjE+btUtAWZtx+HseyaGfqkZK0Z9bT1lsaHecmB203xShwCPT49Blxz VOab8668QpaEOdLGhtvrVYVK7x4skyT3nGWcgDCl5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HVGSJ8grrTJCoACVNhnXg/R0g90g8iV8Q+IBZyDkG0tBThaDdw1B2l asInUTeb9EiVfL/Zjdg5VWiF9LL7iS+9hTeVdR09vThQ/DhVbCNxVk+DtyBHsjOKifrVsYep WpRGBIAu3bK8eXtyvrw1igWTNs2wazJ71+0z2jMzbclKAyRHKU9JdN6Hkkgr2nPb561yjcB8 sIq1pFXKyO+nKy6SZYxOvHxCcjk2fkw6UmPU6/j/nQlj2lfOAgNVKuDLothIxzi8pndB8Jju KktE5HJqUUMXePkAYIxEQ0mMc8Po7tuXdejgPMwgP7x65xtfEqI0RuzbUioFltsp1jUaRwQZ MTsCeQDdjpgHsj+P2ZDeEKCbma4m6Ez/YWs4+zDm1X8uZDkZcfQlD9NldbKDJEXLIjYWo1PH hYepSffIWPyvBMBTW2W5FRjJ4vLRrJSUoEfJuPQ3vW9Y73foyo/qFoURHO48AinGPZ7PC7TF vUaNOTjKedrqHkaOcqB185ahG2had0xnFsDPlx5y In-Reply-To: <20231215074619.173787-1-aravinda.prasad@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/14/23 23:46, Aravinda Prasad wrote: > +static int damon_young_pmd(pmd_t *pmd, unsigned long addr, > + unsigned long next, struct mm_walk *walk) > +{ > + spinlock_t *ptl; > + struct damon_young_walk_private *priv = walk->private; > + > + if (!pmd_present(*pmd) || pmd_none(*pmd)) > + goto out; > + > + ptl = pmd_lock(walk->mm, pmd); > + if (pmd_young(*pmd) || mmu_notifier_test_young(walk->mm, addr)) > + priv->young = true; > + > + *priv->folio_sz = (1UL << PMD_SHIFT); > + spin_unlock(ptl); > +out: > + return 0; > +} There are a number of paired p*_present() and p_*none() checks in this patch. What is their function (especially pmd_none())? For instance, damon_young_pmd() gets called via the pagewalk infrastructure: > static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, > struct mm_walk *walk) > { ... > next = pmd_addr_end(addr, end); > if (pmd_none(*pmd)) { ... > continue; > } ... > if (ops->pmd_entry) > err = ops->pmd_entry(pmd, addr, next, walk); I'd suggest taking a closer look at the code you are replacing and other mm_walk users to make sure the handlers are doing appropriate checks.