From nobody Mon Feb 9 16:50:48 2026 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (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 5BF6E191F74 for ; Mon, 27 Jan 2025 20:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738009600; cv=none; b=hXmBSJsz/qvdEDrbpzqV/s4tcw2td0oxn5kzukpXF94WNTVLC8PIOau2gFQoKUTwr0md0JkzdJuXWbd5ibJrrqlj2bpmJE6uQi32IpUN3q2jJ3talEuQbTR0jRq+x6AqVdAVOEbDhji7sUdir1lyooT96czTnWWJChRbgoKLbUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738009600; c=relaxed/simple; bh=MAzP0x0iv/TpjlAfV26Drn0+MoUVDVGan8HKbiVzpjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jw8E8DtvobRTm9rp+BxPBrcJi1SNdEP30o/pd1PfhWSARN4BTq4g8DS6ZkIozd8AM5aN9AsE16beybgX8cXmn8MMM0BkLZqXowMvqJTL4cRb2CY0FuHBiVJwq6ODY5jX2b3vqxsbvroXkIVCQAmdKnVITBYwRn+i/SmrsSNU/xI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=gPsyGn86; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="gPsyGn86" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XG9SCcwfXhDT64c0QOl2ud2reKcDnLqct8TbwSjXLVE=; b=gPsyGn86tef35rzbiV/IoeXRg6 ECH38SPSboe8afucknovD10ybf4xSQ6KwVZLnnsn7vCsD9EyuWI57WXCGKnf/1K3BDYG36lB/WaRV papn1PXktH2X5gSHjN3UD4raiWwv8eKPurMCMZyMljjTl7Bp5ysYku+SjSHoc+LsVQWZT9DuiISaz y6fDceaMsJ8a4pj/XsRuDI2/6DYg7c16DCOh/+sVbWzfhxYnbPgentQEI/r4Km1+3cnEX7dudqsb/ ny+y3w0qBSaN5jkVIMo6SKLzB7r8jpZQGDhe/1Ryk1Mx5G2nmcg3PqZs2K1CQEvMqFSDBG6PtZXM/ ZOwOXv5w==; Received: from 189-68-33-219.dsl.telesp.net.br ([189.68.33.219] helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tcVgb-003OPi-02; Mon, 27 Jan 2025 21:26:21 +0100 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , Arnd Bergmann , Florian Weimer Cc: linux-kernel@vger.kernel.org, kernel-dev@igalia.com, Vinicius Peixoto , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v2 1/4] futex: Drop ROBUST_LIST_LIMIT Date: Mon, 27 Jan 2025 17:26:05 -0300 Message-ID: <20250127202608.223864-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250127202608.223864-1-andrealmeid@igalia.com> References: <20250127202608.223864-1-andrealmeid@igalia.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="utf-8" Content-Transfer-Encoding: quoted-printable ROBUST_LIST_LIMIT was introduced to avoid the kernel get stuck in circular lists, stopping to handle locks after the limit. This could cause starvation in applications that have very long lists with valid and non repetitive elements. Instead of having a hard limit, rewrite the next pointer list while walking on it. In this way, if the kernel ever revisits a repetitive element (characterizing a circular list) the loop will stop. Signed-off-by: Andr=C3=A9 Almeida --- include/uapi/linux/futex.h | 3 +-- kernel/futex/core.c | 13 +++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h index d2ee625ea189..3f31f38245f9 100644 --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -165,8 +165,7 @@ struct robust_list_head { #define FUTEX_TID_MASK 0x3fffffff =20 /* - * This limit protects against a deliberately circular list. - * (Not worth introducing an rlimit for it) + * Deprecated, do not use. There is no limit of items in a list. */ #define ROBUST_LIST_LIMIT 2048 =20 diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 3db8567f5a44..b1328697d7cc 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -779,7 +779,7 @@ static void exit_robust_list(struct task_struct *curr) { struct robust_list_head __user *head =3D curr->robust_list; struct robust_list __user *entry, *next_entry, *pending; - unsigned int limit =3D ROBUST_LIST_LIMIT, pi, pip; + unsigned int pi, pip; unsigned int next_pi; unsigned long futex_offset; int rc; @@ -820,13 +820,14 @@ static void exit_robust_list(struct task_struct *curr) } if (rc) return; - entry =3D next_entry; - pi =3D next_pi; + /* - * Avoid excessively long or circular lists: + * Avoid circular lists: */ - if (!--limit) - break; + put_user(&head->list, &entry->next); + + entry =3D next_entry; + pi =3D next_pi; =20 cond_resched(); } --=20 2.48.0