From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out28-98.mail.aliyun.com (out28-98.mail.aliyun.com [115.124.28.98]) (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 EC6B5280CFC for ; Tue, 25 Nov 2025 04:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764044118; cv=none; b=D+sWKu3bjqEE/KN31zUZtC+dzb0eJbAju+HQU/NsF9Z1osvkvIBvYVn/s3/RnU7hDF9mdsfuB2AUx3yDGSafwE5/t4z8FCQFyOWyTTZjnhVf9Ucbzep+X3OIaQ3PCAhFq9jz6zdHb2gj6TB1R3fGgnN0sUflgNprPQEKXtMT8/E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764044118; c=relaxed/simple; bh=ZQSNC3I/+neRFPQIuSogKjopeOl8L4AQarHuXDGCsQo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b1DQp01uVoEnkYnk7FUp1LkNy+3OF7ui1PbqMkb7iPL7Q8Q/23kfZMA3QbpdyWrRIMpHqPZd26Fao0AxpHuRaSX8WZgVbjv6N279n6Yh3WV7fOoiU8y1oIILqRU0X82FZ6obe7z07CCGMwwbaJVC5NpGwhgG1ftlTCIuSPrZLKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=Zen4EIRk; arc=none smtp.client-ip=115.124.28.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="Zen4EIRk" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1764044106; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; bh=fRtiZanmwtKqwkfVAA9TfIIn2fu+x2IS/UDDE5SSgjE=; b=Zen4EIRkUwE5XSqKR15wEEcyyS3fET1XmNT0ROY3eZRowWpKD3sYhibzlo42wTYjK83FJbFQD0c9Yjd12CMpz4oAO1cqxVlDw5wRcrCwAFDOupjhczCnqCY13LP9WrSFDa96/ZWKwhgBhg9DraVgxlkFqNW6XaWdVrMeZ6VTJNA= Received: from i85a15111.eu95sqa(mailfrom:junchuan.tzh@antgroup.com fp:SMTPD_---.fVDsBl._1764044103 cluster:ay29) by smtp.aliyun-inc.com; Tue, 25 Nov 2025 12:15:04 +0800 Date: Tue, 25 Nov 2025 12:15:03 +0800 From: Zhiheng Tao To: "David Hildenbrand (Red Hat)" Cc: akpm@linux-foundation.org, lorenzo.stoakes@oracle.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, shy828301@gmail.com, zokeefe@google.com, peterx@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/khugepaged: Fix skipping of alloc sleep after second failure Message-ID: <20251125041503.GA113135@i85a15111.eu95sqa> References: <1763965157-58413-1-git-send-email-junchuan.tzh@antgroup.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: User-Agent: Mutt/1.5.21 (2010-09-15) On Mon, Nov 24, 2025 at 10:14:20AM +0100, David Hildenbrand (Red Hat) wrote: > On 11/24/25 07:19, Zhiheng Tao wrote: > >In khugepaged_do_scan(), two consecutive allocation failures cause > >the logic to skip the dedicated 60s throttling sleep > >(khugepaged_alloc_sleep_millisecs), forcing a fallback to the > >shorter 10s scanning interval via the outer loop > > > >Since fragmentation is unlikely to resolve in 10s, this results in > >wasted CPU cycles on immediate retries. > > Why shouldn't memory comapction be able to compact a single THP in 10s? > > Why should it resolve in 60s? > It may resolve in 10s or 60s. The problem is that the sleep controlled by khugepaged_alloc_sleep_millisecs should not be skipped if allocation fails. > > > >Reorder the failure logic to ensure khugepaged_alloc_sleep() is > >always called on each allocation failure. > > > >Fixes: c6a7f445a272 ("mm: khugepaged: don't carry huge page to the next loop for !CONFIG_NUMA") > > What are we fixing here? This sounds like a change that might be > better on some systems, but worse on others? > > We really need more information on when/how an issue was hit, and > how this patch here really moves the needle in any way. > It works better. The missing of khugepaged_alloc_sleep() is not introduced by this change. Maybe I should remove "Fix". > -- > Cheers > > David