From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F5453E3149 for ; Fri, 20 Mar 2026 18:09:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774030201; cv=none; b=U1S9Ii5FeCBnRHNPvgp1Dt2A/lIXCRbJo2guMOCGwafDs/TJZQasgRo6WAfedJUEN9A6p3Xt5SOudi2/BKkUmH4qvIB1gP5MJVfVGujAkDvq4y059vdx8Ag7v7T51GgUvrlk8kjURWLyEC8P5ccj67NbI7q43FrWPJK+R3USFNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774030201; c=relaxed/simple; bh=tH1dWxhMDlfLbzAn50QMObPX/O01lNxEhE6jff7zQFY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PsyFZP/7CeivjZAHCfo90AAo0rdS0IPgRY2BQnXZlM7s0hU88gAbQ+KwIaOXLMJOGJRj1LPayGZ5X/78S+yoJKtFPTue3VK3jbJq3ZLqVTu/wiaUfA4STmNdxl9dhbVFDVHoONC+OmP862MPUVyrLtbvJQbpNceC8rtLIHKG8+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LhqprHkQ; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LhqprHkQ" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-824c9da9928so2215660b3a.3 for ; Fri, 20 Mar 2026 11:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774030196; x=1774634996; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MWO8/AM4WrEkDVDqOucayyy0y80irblT9jEghfxAXWQ=; b=LhqprHkQVblxStkXArOd/UE/eAeNzRw6tRKqalQDwPIYv93YI1PY/bOa9Nj4eobCNT jOswy3UNBGR34bA+G+QgvGGqx+eOLhYo1cudfAg9Jbygm9BhRNizo8PiIaag8faXzHdX /I+l0XV1GLJU7HqNC2w/TB2ksDZWjlddlz7y3xeBTdP70DOIsHBKf8zHbR821KQ1tgqw qMx9mc5kKlt2c3gej/zDo5FsO6h5YIpUA5qxM13FEQQiQQLrYrxLU9R19y1RIifMTl5K m4UJcyJ2oB70vMEtaoDoLlNJJIk9StBwfLi2la9eCULpUBRWmOwwzFwGO4fO8YiT34SO HZPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774030196; x=1774634996; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MWO8/AM4WrEkDVDqOucayyy0y80irblT9jEghfxAXWQ=; b=YGHfCh/YU4oWl/uYksp4gtrT5rRpVSh3GpEHixuL1VLkV+JNe0JWvbIKgaMi52SjiM 4Ccj19m6lKtxL7lOMjXVDHwwYfpHVsp92Q5uDBSMa+MWem5ilsCNAgz/al/wbaUVAkpY TPafAc6CwO0ulvu3ElOUN9dGukgjg4k8bOb7ibZKb0+N0v+/JTq/cpsw6ApzLrBvbl3F RDuRNQH5TPudh4czjbP4HnysKRK+iz0+RPP2irNgCFRbC3kTcUEDq89iShpVklU+tqX3 GtJj7+y8AVuWwyZb5UflZFuUCWurGrRQGM7cgT1334hLjeJRAuVhDLMl5ZA9OtIOMwes kPVw== X-Forwarded-Encrypted: i=1; AJvYcCX+DThWrfa0FM6IdonyzrOB2RiUomnW/s/HVaUoBkyyUX0XezZ9/HybZ1sF/mC5K0OLI3e3xCn97oBFFe0=@vger.kernel.org X-Gm-Message-State: AOJu0YyOoLdi6n4+JDXxNPJo0oQlVIIAbzU/8Hcx9AwAxp8ySk1Qpw2B FJ7II3FpJQeI9Ro+RLlTpPshLsvAf/ITTk5c5w0CTTnZc1zgjf5zXq5p X-Gm-Gg: ATEYQzz0ifn8NGdHdrv92art1uCPs2lHp9XdqPST6OYwVKzQHNskJBlWdXe4Sx113N3 IRi98ci7afoD+KLBqcjM6frpMEiAx6wNBzIv6GyTiqbpn1RuNqApWjG3psvKubspFpCws9m+qJ+ g+SIZcMLaI+T0z+y6TTyyZfYjKJZE+9m0emi+RsFRxvIonSD9YE9HZFo3iOfIekxdGXwQd+ikv9 z0xUw/VKp9IJkmjyPpuN7IlyxW849W8oxqInwLW+sWXu13T0GlJXLZgPwXh8wG8qja5lhPGDech WP3e7O7NxmPQrDgn1czKF6KcT3BmEdNHiP7SiqYMNxmGlgsl6jvMbOchYpAI0MESJSpFL4imHnV ACFm37SkjfwU3EcIkFAZ/VvlKv7/2ggs3S9ObQ30LvOEQA6E0fss+AFdyrtC8XN87qz3EK/H/nE jpg2zb4B30DsmJy5u5nQ0GqV+31dNYzrgK96QcyMtiPnOI+3wYdgUv5hUkpCU7j+LnDPi2ykTD6 IF7fkt5ioo4Rpf/qAoNJlbjRKfMWQODe/D8WEQBsq0Y5bxGvg== X-Received: by 2002:a05:6a00:928f:b0:829:7e6d:cf12 with SMTP id d2e1a72fcca58-82a8c27b910mr3460151b3a.18.1774030196280; Fri, 20 Mar 2026 11:09:56 -0700 (PDT) Received: from visitorckw-work01.c.googlers.com.com (100.130.194.35.bc.googleusercontent.com. [35.194.130.100]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82b040d7e56sm2582318b3a.40.2026.03.20.11.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 11:09:55 -0700 (PDT) From: Kuan-Wei Chiu To: richard@nod.at, akpm@linux-foundation.org Cc: chengzhihao1@huawei.com, hch@infradead.org, jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com, marscheng@google.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH v3 0/2] lib/list_sort: Clean up list_sort() scheduling workarounds Date: Fri, 20 Mar 2026 18:09:36 +0000 Message-ID: <20260320180938.1827148-1-visitorckw@gmail.com> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Historically, list_sort() included a hack in merge_final() that periodically invoked dummy cmp(priv, b, b) calls when merging highly unbalanced lists. This allowed the caller to invoke cond_resched() within their comparison callbacks to avoid soft lockups. However, an audit of the kernel tree shows that fs/ubifs/ has been the sole user of this mechanism. For all other generic list_sort() users, this results in wasted function calls and unnecessary overhead in a tight loop. Recent discussions and code inspection confirmed that the lists being sorted in UBIFS are bounded in size (a few thousand elements at most), and the comparison functions are extremely lightweight. Therefore, UBIFS does not actually need to rely on this mechanism. --- Changes in v3: - Abandoned the idea of introducing a new list_sort_nonatomic() API. - Removed the dummy cmp() hack. - Dropped the cond_resched() calls from UBIFS. - Split the changes into a 2-patch series. - Dropped Zhihao Cheng's Reviewed-by tag due to the fundamental change. Changes in v2: - Dropped the u8 count rate-limiter in merge() and merge_final(). - Removed cond_resched() calls from UBIFS comparison callbacks. v2: https://lore.kernel.org/lkml/20260317165905.1482256-1-visitorckw@gmail.com/ v1: https://lore.kernel.org/lkml/20260315193900.218737-1-visitorckw@gmail.com/ Kuan-Wei Chiu (2): ubifs: Remove unnecessary cond_resched() from list_sort() compare lib/list_sort: Remove dummy cmp() calls to speed up merge_final() fs/ubifs/gc.c | 2 -- fs/ubifs/replay.c | 1 - lib/list_sort.c | 9 --------- 3 files changed, 12 deletions(-) -- 2.53.0.959.g497ff81fa9-goog