From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 F06E030BF7E for ; Tue, 13 Jan 2026 07:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768289528; cv=none; b=hJaMtuW+1PhfM7hFkEECYltgH3rXwTaHJdB2fGq+KOSOnfi74nXEYq1RpmJM3H2IK7r48w3xgEYQYxuVD03RMOVVEuho1nFUfgepeYj9W6YIETsmPcnJ0MrGVR6VIU8igyIZM9UtI0aoTPrlhgBme6b+1TnNo9ie3rIQYGVct+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768289528; c=relaxed/simple; bh=lgTmpSMMsag98ez4AA3v7IyhJa3QYF7dDvyAe8We+Ps=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=aAH4soiAWMNzkU/EoYFfZePty6nIE9vNCdwbTSaOXxsCk9ayNZqQ7tY4BejfLfUumiFf+SmCzGhvA32I0/27NzkYRBhGS4kxDYkZIq7+nMnYXFHj4m/8Ck1I7jAaAx0aG+3lmcgFzJHvJiueyI7WfqX6ZQ2uJGbPpXVJZKPAgJM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=h-partners.com; spf=pass smtp.mailfrom=h-partners.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=h-partners.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Received: from mail.maildlp.com (unknown [172.18.224.83]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4dr1CM5PGlzHnH51; Tue, 13 Jan 2026 15:31:43 +0800 (CST) Received: from mscpeml500003.china.huawei.com (unknown [7.188.49.51]) by mail.maildlp.com (Postfix) with ESMTPS id 4726840086; Tue, 13 Jan 2026 15:32:01 +0800 (CST) Received: from [10.123.123.67] (10.123.123.67) by mscpeml500003.china.huawei.com (7.188.49.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 13 Jan 2026 10:31:57 +0300 Message-ID: Date: Tue, 13 Jan 2026 10:31:55 +0300 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: [RFC PATCH 0/2] mm: improve folio refcount scalability To: Kiryl Shutsemau CC: , , , , , , , , , , , , , , , , , , , , , , , , , References: Content-Language: en-US From: Gladyshev Ilya In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100012.china.huawei.com (7.191.174.184) To mscpeml500003.china.huawei.com (7.188.49.51) On 1/12/2026 7:17 PM, Kiryl Shutsemau wrote: > On Mon, Jan 12, 2026 at 05:32:10PM +0300, Gladyshev Ilya wrote: >> On 1/12/2026 2:49 PM, Kiryl Shutsemau wrote: >>> On Mon, Jan 12, 2026 at 11:30:38AM +0300, Gladyshev Ilya wrote: >>>> Gentle ping on this proposal >>> >>> I generally like the idea, but I would like to hear from folks who >>> actually understand serialization. >>> >>> Also, do you have number for "a full CAS loop when the counter is >>> approaching overflow" thing? >>> >> I am not sure that overflow is a real problem because you need a very >> specific race condition over a long time to achieve it... > > Yes. But if the page is popular for pinning, GUP_PIN_COUNTING_BIAS can > cut the "very long time" substantially. > >> But as a safeguard, everything lower than 2^31 - #max concurrent >> accesses (~#num cpu) should work, so let's say 2^30 > > What I meant is when we put a branch/loop in the hot path, your > performance numbers will likely not look as attractive. Am I wrong? > It would be under the same branch as the single CAS that already exists in this patch: if (page_count_writable(page)) { val = atomic_add_return(nr, &page->_refcount); ret = !(val & PAGEREF_LOCKED_BIT); if (unlikely(!ret)) { atomic_cmpxchg_relaxed(&page->_refcount, val, PAGEREF_LOCKED_BIT); /* [Proposed] if (failed && big enough) { CAS loop } */ } } Unless the "failed try_lock()" is the hot path somewhere[1], this added branch will be hidden under the already existing [unlikely taken] branch [1]: Which I doubt, because failed try_lock() usually includes heavy re-lookup