From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 7EB1640DFB9 for ; Sat, 21 Mar 2026 02:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774058785; cv=none; b=R2wMDoDMVZhXb5HwT29E+BYlkoHaUTqqk3sW32gr4Lv0ZMgsBs5k68jZf6n33zY7fFQLKyANK360vchC6eYcfiBmtOrsxGR8h0kzL4D3gkDjt/g124T2d6WQXA2+iUxlHYe32FL8W+PTQLM/T8TsU2s69QzI9FCDuJXZL0qc0T8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774058785; c=relaxed/simple; bh=hmmMzmkV/Wqw65XDouf7xAywuSuAVQMbzxYVK7qEzP4=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=IbaVhHOVFRu0QrWt3LzXQoRL5+51rkmxTjZvfCXkSk2mo7xUJghYLYilwcOU9NJmCS6yasO6+MqIWUw2lMTRR6G+pDitpGrCtu04thSnxJuLnzq8aVTVG7YFPiU1Dg8/g1tV57SMtI5XynvMGjeSJ6aPlP69Grg6cT+2Tper/Wc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=i+c2I+iH; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="i+c2I+iH" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=IVfCdhG3Bimzj6BX6QA3XU1WORmYKRToU188kgbX1AU=; b=i+c2I+iH4ApXDPVY9+tLYGflmbj1QMQQsFatucRkenzSAJM0GoYU9oqpwanuh1r0exJ8xJlZY YXq7OjNftSK1nJ3h1Q7EV5D6Ab7eLN/ZBvyELlXZ9sgeybZPoff1hIFp3Qz98NW7Ji10Js2PJgR glXnXFTf6L6Ji5BGfhPhDdM= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4fd2hN0ddSzcZyQ; Sat, 21 Mar 2026 10:00:36 +0800 (CST) Received: from kwepemk500005.china.huawei.com (unknown [7.202.194.90]) by mail.maildlp.com (Postfix) with ESMTPS id 130442012A; Sat, 21 Mar 2026 10:06:20 +0800 (CST) Received: from [10.174.178.46] (10.174.178.46) by kwepemk500005.china.huawei.com (7.202.194.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 21 Mar 2026 10:06:19 +0800 Subject: Re: [PATCH v3 1/2] ubifs: Remove unnecessary cond_resched() from list_sort() compare To: Kuan-Wei Chiu , , CC: , , , , , References: <20260320180938.1827148-1-visitorckw@gmail.com> <20260320180938.1827148-2-visitorckw@gmail.com> From: Zhihao Cheng Message-ID: <2fdb7cfc-f993-80bf-2519-1614ccd342c5@huawei.com> Date: Sat, 21 Mar 2026 10:06:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20260320180938.1827148-2-visitorckw@gmail.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemk500005.china.huawei.com (7.202.194.90) ÔÚ 2026/3/21 2:09, Kuan-Wei Chiu дµÀ: > Historically, UBIFS embedded cond_resched() calls inside its > list_sort() comparison callbacks (data_nodes_cmp, nondata_nodes_cmp, > and replay_entries_cmp) to prevent soft lockups when sorting long > lists. > > However, further inspection by Richard Weinberger reveals that these > compare functions are extremely lightweight and do not perform any > blocking MTD I/O. Furthermore, the lists being sorted are strictly > bounded in size: > - In the GC case, the list contains at most the number of nodes that > fit into a single LEB. > - In the replay case, the list spans across a few LEBs from the UBIFS > journal, amounting to at most a few thousand elements. > > Since the compare functions are called a few thousand times at most, > the overhead of frequent scheduling points is unjustified. Removing the > cond_resched() calls simplifies the comparison logic and reduces > unnecessary context switch checks during the sort. > > Signed-off-by: Kuan-Wei Chiu > --- > fs/ubifs/gc.c | 2 -- > fs/ubifs/replay.c | 1 - > 2 files changed, 3 deletions(-) Reviewed-by: Zhihao Cheng > > diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c > index 0bf08b7755b8..933c79b5cd6b 100644 > --- a/fs/ubifs/gc.c > +++ b/fs/ubifs/gc.c > @@ -109,7 +109,6 @@ static int data_nodes_cmp(void *priv, const struct list_head *a, > struct ubifs_info *c = priv; > struct ubifs_scan_node *sa, *sb; > > - cond_resched(); > if (a == b) > return 0; > > @@ -153,7 +152,6 @@ static int nondata_nodes_cmp(void *priv, const struct list_head *a, > struct ubifs_info *c = priv; > struct ubifs_scan_node *sa, *sb; > > - cond_resched(); > if (a == b) > return 0; > > diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c > index a9a568f4a868..263045e05cf1 100644 > --- a/fs/ubifs/replay.c > +++ b/fs/ubifs/replay.c > @@ -305,7 +305,6 @@ static int replay_entries_cmp(void *priv, const struct list_head *a, > struct ubifs_info *c = priv; > struct replay_entry *ra, *rb; > > - cond_resched(); > if (a == b) > return 0; > >