From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 3C20E34DB79 for ; Fri, 19 Dec 2025 16:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766160588; cv=none; b=D2Xor5M97THutCPV+CfIrNMloxvU0XeO8613yEdoSvzq8Rx7ADD8V4+KPA5HUmISH6GAPtBc0x2pW6fbQp9+nE+2u/Z6pa4tu5qtW1/4/CCBlcz7/m1mzUWsLGemJmdIto9SLSm1sjjsvD18nzHClaZzM+/VJjb/IPEuXbiDc6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766160588; c=relaxed/simple; bh=zficx96Ib0BYIbk8t3W+nAOPdndP9Nj3/IwfJf4Ha0c=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mvSlJ31dnbOYbiDxDoczwz2J+Qhjx9CxqaZ71Ad0J1fZnYdnknYdJzGWf3TXonzJD6i+6KJJ2ugZMbQw/9PFIcsUi9C/ULN7+2ZGJq+76WVXKzwQkpi5fVg/U9wtUu8dLSb5KNncv6vBGqYE9bf24Bkg8EodC/W1giQvFpHc3kM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=cQPXOwId; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cQPXOwId" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=z0mjmGpOW60lNIbtFI+r1yzZWjFojlQMo6AcrdT+eeU=; b=cQPXOwIdyvnpu/TFP07Kw09C6Z Zgy1qKTMnuFS26B8P+aXQyJg4yZg3HLAkX0xEcQUFb9VBegbEKRjkggUWliQXDkfWH05DkjXRjOzA C4BLRuOUlXgUUmKsfkfx6kx3zmv2NSgsK+y1W8xs4lHqP0rFqJVj1TuUoQKMEBLGbF3mTb79Q6zEJ qP6HF/hiSnTrGdltfke63GdUe/UA+lwz6mkGqCjTkGmeZojrYwKo2MrL2Q1VmR3IzbxpjnDBUzzdf Cfjw6depJXCBUEYA599KPGQpKSdlZIdHm/i8FF7iqSZ1+vNinkRhiBYj74IVjkx4IUl5Mq6kSTNQy n2YND57A==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vWd2p-00000007n7R-3Bk1; Fri, 19 Dec 2025 16:09:31 +0000 Date: Fri, 19 Dec 2025 16:09:31 +0000 From: Matthew Wilcox To: "Liam R. Howlett" , Baolin Wang , akpm@linux-foundation.org, david@kernel.org, catalin.marinas@arm.com, will@kernel.org, lorenzo.stoakes@oracle.com, ryan.roberts@arm.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, baohua@kernel.org, dev.jain@arm.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/5] mm: rmap: support batched checks of the references for large folios Message-ID: References: <24b9d33acad627997febe9b61d398fc53739a333.1766121341.git.baolin.wang@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Dec 19, 2025 at 10:47:52AM -0500, Liam R. Howlett wrote: > > -#define ptep_clear_flush_young_notify(__vma, __address, __ptep) \ > > +#define ptep_clear_flush_young_notify(__vma, __address, __ptep, __nr) \ > > ({ \ > > int __young; \ > > struct vm_area_struct *___vma = __vma; \ > > unsigned long ___address = __address; \ > > - __young = ptep_clear_flush_young(___vma, ___address, __ptep); \ > > + unsigned int ___nr = __nr; \ > > + __young = clear_flush_young_ptes(___vma, ___address, __ptep, ___nr); \ > > __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \ > > ___address, \ > > ___address + \ > > - PAGE_SIZE); \ > > + nr * PAGE_SIZE); \ > > Did you mean nr * PAGE_SIZE here? I think it should be __nr or ___nr? > I think this nr variable works because it exists where this macro is > expanded? Yes, this should clearly be ___nr. > I am also not sure why you have ___nr at all? It's a macro cleanliness thing. Imagine that we have a caller: a = ptep_clear_flush_young_notify(vma, addr, ptep, nr++); If you have two references to the __nr macro argument, then you end up incrementing nr twice. Assigning __nr to ___nr and then referring to ___nr within the macro prevents this. That said, I'm not sure why ptep_clear_flush_young_notify() needs to be a macro instead of a static inline?