Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1288968rbb; Mon, 26 Feb 2024 05:04:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVwrRoHn+tpJCWnouJGoGdJfl8HwJKPoC6IF0ee+FnV57G6vsrhFUy+PPVEk+fR7IHp84gdTpPN9W47ubC2D4P1b12Wx8PxyodfpCyLQA== X-Google-Smtp-Source: AGHT+IE2pfmRoTEdGuX4EpvXVv5QMuniFKuBdnfuGvbN+Ihm26CNzVX7pQl2IWCEJjrJdvKCZm+i X-Received: by 2002:a05:620a:136c:b0:785:d8a1:dfbd with SMTP id d12-20020a05620a136c00b00785d8a1dfbdmr7946521qkl.68.1708952664051; Mon, 26 Feb 2024 05:04:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708952664; cv=pass; d=google.com; s=arc-20160816; b=FRfB8E5iiOszizf5KBuCI9FtL1rU96JTBC7nqipHt8ymG+ILljksJSbT1ibkLR7IL8 QuXVDwXJlq6HRmADJVGzyPz3O8enrtQP76eTKJmmOP4MlQLUQEQNIhl3McXHstceuxQs 8ctS5v1fEjMsVsqCPsKRvH+I4gkU2FgnAu+GgyFXxUnlU0Gk009Nc6L7HP13DmEE5vof 9QbXr5WY1tr4pJqyX7/9uAsZ8i7vc8oA8aMhI0Pv+emnCGL5ckAnc3m+eaZCdHVocI52 B2U42xyCvVdDHRNPEceGlSFmz9TzT/2xmfyvIC1zQnJz8RncaW4qgNPV2KdD4CU3XrKm s0PA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=yjazdN8RBWFvqhPGMDx7Y36Oy/jbIeEjbI482XY1prE=; fh=/5iKVPB5cihK1o/x2sL9n5/kmqcT7OVtiNxB79R/gY4=; b=QPTvel5tDHwDr5qujN40HpOx8uzQcOAFlDWBXOWia5K3fNs+XHEyO2VgVrQMo6GF7K Mf/w37TTALp7r3QZJP7RnGeWxAeJxqC7wApAEmQokrgKwocYNdiWc0hzvyE/V1TDPWsy CSOpWOXTWtT0POhi6w2WTmRzHxdd9BfWNFeM6ahziea1GHd8ywyAtDYxMdmH2ITXOd6u FbhqhWbyDATH4JU+ByhU5BwqxDzQy2Ps+ccz7ESy7hhm/cRHrooPXiGNDAEuajvqSYjb hwJG95WUub0vrdAjtCP5r1F4JBFdXaVygjnNEDhKRiy1kvfntN5Sc343IXb+JV2/ogPd +k2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-81438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id xz19-20020a05620a5e1300b00787cb3045d3si3567360qkn.365.2024.02.26.05.04.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:04:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-81438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B93881C20F46 for ; Mon, 26 Feb 2024 13:04:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B78077FBD8; Mon, 26 Feb 2024 13:04:18 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5B867F7F9 for ; Mon, 26 Feb 2024 13:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708952658; cv=none; b=ZIFtibPnpyb0L8QqD5tEQTaG32XlozMJ0eotgvOsJW029jKGiq6RBWxZl8GGTr8xpDv3QCxsyMSxkBUoiJK36KIN0OWWiu5/P0rSfUnT8wfNGvUYktHWEt9Jp9KBLSMZ/plzEXo8VSVJyZra15qEu8xXkxA/bpw2CC2PVadfiKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708952658; c=relaxed/simple; bh=NLg6QYanoeqzWqGaHoMhjzpszT/KgDkGZ09M4+9jIsk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=X8XSfCA9A4VP239N8uCUh+j/TIZSz17jWmxbgTqZ0O0b6jNGKSG7zHzIpmMgHm/CDrzbQAtM3BojnGO7Ll4Lnbjt1EHAwlQAunvj0zDClSww+uzK1MoxxUz9guJpQ8UlNr5OO2e4APVw1lA2iZCze4gqpEI18zZiHE5iLmwI4u0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 70626DA7; Mon, 26 Feb 2024 05:04:54 -0800 (PST) Received: from [10.57.67.4] (unknown [10.57.67.4]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 291613F762; Mon, 26 Feb 2024 05:04:13 -0800 (PST) Message-ID: <318be511-06de-423e-8216-af869f27f849@arm.com> Date: Mon, 26 Feb 2024 13:04:11 +0000 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: [PATCH 1/1] mm/madvise: enhance lazyfreeing with mTHP in madvise_free Content-Language: en-GB To: Lance Yang , David Hildenbrand Cc: 21cnbao@gmail.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, minchan@kernel.org, peterx@redhat.com, shy828301@gmail.com, songmuchun@bytedance.com, wangkefeng.wang@huawei.com, zokeefe@google.com, fengwei.yin@intel.com References: <20240226083714.26187-1-ioworker0@gmail.com> <9bcf5141-7376-441e-bbe3-779956ef28b9@redhat.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 26/02/2024 08:55, Lance Yang wrote: > Hey David, > > Thanks for your suggestion! > > On Mon, Feb 26, 2024 at 4:41 PM David Hildenbrand wrote: >> > [...] >>> On Mon, Feb 26, 2024 at 12:00 PM Barry Song <21cnbao@gmail.com> wrote: >>> [...] >>>> On Mon, Feb 26, 2024 at 1:33 AM Lance Yang wrote: >>> [...] > [...] >>> +static inline bool pte_range_cont_mapped(pte_t *pte, unsigned long nr) >>> +{ >>> + pte_t pte_val; >>> + unsigned long pfn = pte_pfn(pte); >>> + for (int i = 0; i < nr; i++) { >>> + pte_val = ptep_get(pte + i); >>> + if (pte_none(pte_val) || pte_pfn(pte_val) != (pfn + i)) >>> + return false; >>> + } >>> + return true; >>> +} >> >> I dislike the "cont mapped" terminology. >> >> Maybe folio_pte_batch() does what you want? > > folio_pte_batch() is a good choice. Appreciate it! Agreed, folio_pte_batch() is likely to be widely useful for this change and others, so suggest exporting it from memory.c and reusing as is if possible. > > Best, > Lance > >> >> -- >> Cheers, >> >> David / dhildenb >>