Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1800441rbb; Tue, 27 Feb 2024 01:14:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvGnlslcHHU0uoukuX8fiRZykYncRf2uARIsoSjL306nIVox4OXYu5xcLIgk/lV3yteWy9VUhWjRnyWoK6fpjfItg2m87/cjsVj274NQ== X-Google-Smtp-Source: AGHT+IFjZ3H2IwQnhXGjRG3yYQrom1lXZX8N3FTZQJET0AZIpQlJdgHsKtE3SUj/D8L8ubqKcLJC X-Received: by 2002:a17:903:41cb:b0:1dc:38c7:ba1a with SMTP id u11-20020a17090341cb00b001dc38c7ba1amr11983750ple.25.1709025252800; Tue, 27 Feb 2024 01:14:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709025252; cv=pass; d=google.com; s=arc-20160816; b=UW9v/0vjJAC9xRkOBeU7QlTWEm1zthgpXZwgHoVhodqAdrrwtEXrtlqx9SztJ608kl cYFD4gOk3rOEpPqIFKYblNmXR9QmR61aih4GLs3BrukoOzHVTl8eIGGsOTjEu9qCwBav zkF9eTNZOgJkstoE2/lP4C7P5QAa50x2GiVreFllOvkmMJkEKEf3mTIdbMR4wNrm29qK OAMdUT8tBaUJwg2glmJi57/V9hk6QaO+ypZ08a3SkdDyts3Q1+2E+97BqFZz3fxUpnvo nmTzf/yvL0LF/aG7Mzlw0iL7utnU39OYHOvc2U2//Wmj+XseX9M346zJRU5MwV/Ngk1L 9BQA== 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=el80kYtmZhhRPD7Q8o3YzcBeJPvcrYCvtEcltm9M3R0=; fh=xIrkjQ5hmt7Be6TYcOOH3QtxTvBzUkkJ+Py0BOW/iE4=; b=l1aKS5pdehTdALsUBLBOkBdIjCU8AobbgZrgqKUiBaX0rKINV2kNTg6JjovEEAmvTa JBLPmSRiVMCe24KKF7DYkjlFT94Rv9GbTtNB0XJrqkZQdgoKnoekwVo4KfbM/Y0qe4oQ Ph/DVeqJ2mxtRnbF44K/ep04b0RQxOfJ/+VXXoTvxDZDoPlh7Zv4JFgIIFouPYP1GdoH V2cvMqNQFZba0OFPdNb2iP+domsduy+aKQIZpqvM9MJa0CKWqDl/gjYtXQpIP/3LRBI6 tK0GRXVV6q8xqIIYN1sIdbMEl459uWVQchVLTN3S2pBye154xz5fX7SzQR6nOnTBnrOZ P5Rg==; 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-82930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 k5-20020a170902d58500b001db608107d8si1101432plh.203.2024.02.27.01.14.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 01:14:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82930-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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-82930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82930-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 827BB280D8F for ; Tue, 27 Feb 2024 09:14:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD39913666C; Tue, 27 Feb 2024 09:11:40 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8265136657 for ; Tue, 27 Feb 2024 09:11:37 +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=1709025100; cv=none; b=TxqzIvoXr+qvg9uq3YFNQ8pZVaZcaxqUvuBrJRGpkKpSG4YZPXX3bo9uJkyf3fZ+jCnMY49hr8qlw+UtwjJsX9TKb5i3kjgYt+tjv0t1A7bxWtw79VITJ1TOrkLomId7uCbRQ5eT+i1l55amuyRUpuOp9mRszno30t1KSuOmgi8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025100; c=relaxed/simple; bh=qMLHym6yNvFLmUfm3UsVaWLkuqL0S1B5ZeBX1KCN1VA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=meNAQsRIUOdpyijGy40kCVluJNaupELcV1267j3ZAgN9VRaBo34BC6D0FJDbLX7lszyuwkDtE2wGsa+yGqf7egWxRt8S/Wo9zHMY0f+wtwwhKr0lTQ3imx31JiDghhjxvppJJFMnHkZmnCT0TmbM/LulIdwkc/kBsTDdu4n21tM= 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 8C163DA7; Tue, 27 Feb 2024 01:12:15 -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 CB49E3F762; Tue, 27 Feb 2024 01:11:35 -0800 (PST) Message-ID: <4c3d1891-e784-4599-9640-4ff092ba7a31@arm.com> Date: Tue, 27 Feb 2024 09:11:35 +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] mm: export folio_pte_batch as a couple of modules might need it Content-Language: en-GB To: Barry Song <21cnbao@gmail.com>, akpm@linux-foundation.org, linux-mm@kvack.org, David Hildenbrand Cc: linux-kernel@vger.kernel.org, Barry Song , Lance Yang , Yin Fengwei References: <20240227024050.244567-1-21cnbao@gmail.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 27/02/2024 03:18, Barry Song wrote: > On Tue, Feb 27, 2024 at 3:41 PM Barry Song <21cnbao@gmail.com> wrote: >> >> From: Barry Song >> >> madvise and some others might need folio_pte_batch to check if a range >> of PTEs are completely mapped to a large folio with contiguous physcial >> addresses. Let's export it for others to use. >> >> Cc: Lance Yang >> Cc: Ryan Roberts >> Cc: David Hildenbrand > > Hi David, Ryan, > > Sorry, I realize I just made a mistake and your tags should be both > Suggested-by. Please feel > free to review the patch and give comments. I will fix the tags > together with addressing your > review comments in v2. Don't worry about it. Don't feel you need to update it on my account. > >> Cc: Yin Fengwei >> Signed-off-by: Barry Song >> --- >> -v1: >> at least two jobs madv_free and madv_pageout depend on it. To avoid >> conflicts and dependencies, after discussing with Lance, we prefer >> this one can land earlier. >> >> mm/internal.h | 13 +++++++++++++ >> mm/memory.c | 11 +---------- >> 2 files changed, 14 insertions(+), 10 deletions(-) >> >> diff --git a/mm/internal.h b/mm/internal.h >> index 13b59d384845..8e2bc304f671 100644 >> --- a/mm/internal.h >> +++ b/mm/internal.h >> @@ -83,6 +83,19 @@ static inline void *folio_raw_mapping(struct folio *folio) >> return (void *)(mapping & ~PAGE_MAPPING_FLAGS); >> } >> >> +/* Flags for folio_pte_batch(). */ >> +typedef int __bitwise fpb_t; >> + >> +/* Compare PTEs after pte_mkclean(), ignoring the dirty bit. */ >> +#define FPB_IGNORE_DIRTY ((__force fpb_t)BIT(0)) >> + >> +/* Compare PTEs after pte_clear_soft_dirty(), ignoring the soft-dirty bit. */ >> +#define FPB_IGNORE_SOFT_DIRTY ((__force fpb_t)BIT(1)) >> + >> +extern int folio_pte_batch(struct folio *folio, unsigned long addr, >> + pte_t *start_ptep, pte_t pte, int max_nr, fpb_t flags, >> + bool *any_writable); >> + >> void __acct_reclaim_writeback(pg_data_t *pgdat, struct folio *folio, >> int nr_throttled); >> static inline void acct_reclaim_writeback(struct folio *folio) >> diff --git a/mm/memory.c b/mm/memory.c >> index 1c45b6a42a1b..319b3be05e75 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -953,15 +953,6 @@ static __always_inline void __copy_present_ptes(struct vm_area_struct *dst_vma, >> set_ptes(dst_vma->vm_mm, addr, dst_pte, pte, nr); >> } >> >> -/* Flags for folio_pte_batch(). */ >> -typedef int __bitwise fpb_t; >> - >> -/* Compare PTEs after pte_mkclean(), ignoring the dirty bit. */ >> -#define FPB_IGNORE_DIRTY ((__force fpb_t)BIT(0)) >> - >> -/* Compare PTEs after pte_clear_soft_dirty(), ignoring the soft-dirty bit. */ >> -#define FPB_IGNORE_SOFT_DIRTY ((__force fpb_t)BIT(1)) >> - >> static inline pte_t __pte_batch_clear_ignored(pte_t pte, fpb_t flags) >> { >> if (flags & FPB_IGNORE_DIRTY) >> @@ -982,7 +973,7 @@ static inline pte_t __pte_batch_clear_ignored(pte_t pte, fpb_t flags) >> * If "any_writable" is set, it will indicate if any other PTE besides the >> * first (given) PTE is writable. >> */ >> -static inline int folio_pte_batch(struct folio *folio, unsigned long addr, >> +int folio_pte_batch(struct folio *folio, unsigned long addr, >> pte_t *start_ptep, pte_t pte, int max_nr, fpb_t flags, >> bool *any_writable) >> { >> -- >> 2.34.1 >> > > Thanks > Barry