From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9054221F24 for ; Thu, 5 Feb 2026 14:30:22 +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=1770301823; cv=none; b=JBpco+EDJ8AULsOENIxPOAIYNSO6IZ3qDYy71jFnH3Vvoc51acFad47t0OwNtRxo2as2AHS1Lzg3kGJjVNB/VxCjkKBVMUf6E816bqeGvE3AaNpGgB0mEATFVJ9Q+8cL6Z8z4hyDRmulls4RA26Ax+epLYsqK9gSNPhTmF7ftQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770301823; c=relaxed/simple; bh=kbGuWUKKZxIJ4VyHIs2tT7Am3jzrWJWN1tlp8PnhERU=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=eBAXirnu/qIIYzE9Ky0UQjBbcUf/QUD4FkETKGaS7M2o/bsxBHIcbvsOJW5ESMOhb0/eTQz0kQXAHuTU9YzEtQ/ExqOQzr1FtcntcxtYT80h73uyxVxkWsS3WKLTJrylxB8aQ66FPFGkOxqmm9SwRweQPT+uivDa/9R6Sc5LemE= 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 EB4F3339; Thu, 5 Feb 2026 06:30:15 -0800 (PST) Received: from [10.163.132.75] (unknown [10.163.132.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D94F13F73F; Thu, 5 Feb 2026 06:30:18 -0800 (PST) Message-ID: Date: Thu, 5 Feb 2026 20:00:15 +0530 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-new v6 2/5] mm: khugepaged: refine scan progress number From: Dev Jain To: "David Hildenbrand (arm)" , Vernon Yang Cc: akpm@linux-foundation.org, lorenzo.stoakes@oracle.com, ziy@nvidia.com, baohua@kernel.org, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vernon Yang References: <20260201122554.1470071-1-vernon2gm@gmail.com> <20260201122554.1470071-3-vernon2gm@gmail.com> <85e8ded9-a9eb-4663-9c96-93af60006fb6@kernel.org> <9508744b-e5d5-49ef-825f-eef683892541@arm.com> Content-Language: en-US In-Reply-To: <9508744b-e5d5-49ef-825f-eef683892541@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 05/02/26 7:55 pm, Dev Jain wrote: > On 05/02/26 5:41 pm, David Hildenbrand (arm) wrote: >> On 2/5/26 07:08, Vernon Yang wrote: >>> On Thu, Feb 5, 2026 at 5:35 AM David Hildenbrand (arm) >>> wrote: >>>> [...] >>>> >>>>> +     if (cur_progress) { >>>>> +             if (_pte >= pte + HPAGE_PMD_NR) >>>>> +                     *cur_progress = HPAGE_PMD_NR; >>>>> +             else >>>>> +                     *cur_progress = _pte - pte + 1; >>>> *cur_progress = max(_pte - pte + 1, HPAGE_PMD_NR); >>> I guess, your meaning is "min(_pte - pte + 1, HPAGE_PMD_NR)", not max(). >> Yes! >> >>>> ? >>>> >>>> It's still a bit nasty, though. >>>> >>>> Can't we just add one at the beginning of the loop and let the compiler >>>> optimize that? ;) >>> I'm also worried that the compiler can't optimize this since the body of >>> the loop is complex, as with Dev's opinion [1]. >> Why do we even have to optimize this? :) >> >> Premature ... ? :) > > I mean .... we don't, but the alternate is a one liner using max(). > > The objective is to compute the number of iterations of the for-loop. > > It just seems weird to me to track that in the loop, when we have the > > loop iterator, which *literally* does that only. I realize I shouldn't have bolded out the "literally" - below I wrote that I won't shout, but the bold seems like shouting :) > > > > Anyhow, I won't shout in any case : ) If you deem incrementing in the > > loop prettier, that's fine. > >