From nobody Mon Feb 9 16:51:37 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 985B8BA50 for ; Fri, 10 Jan 2025 20:05:36 +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=1736539539; cv=none; b=VEfIfA1a/7KVzgckWDB9s7y6m5/C1+S6wFt57jDb9BKaXIU8qxGpA0ENMxP+ePJepg0UwbB/goQng7CJfx6XN5OYrC+wii5c8qJtxyhswjYjeA9q/pTwL8CBCjkb6I2EIPgqncbjUaoA/eL6ff8mLfeyYOmk/5h1EByCdRPfZ7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736539539; c=relaxed/simple; bh=zWHeteOv9ViJxKSjsnihyr65MydGr4v/vyFDhahDO/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Af02PmuyNxngxVtiqwFYqiqvZaHB1igZSwdahghEpwcl/aQ4As3DspQ5PszcuLB/T5UUV0aOZpkqaXG9/bxNzDczirizGAKH2N/aYdxV6ycfQMTugcCE0p5hMoOl9NR6c8Cbl9hE+Z8c38nt3Snf4U7EMQtBsQ4B4NVw9RaI9VY= 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=Xm3AqaAH; 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="Xm3AqaAH" 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=+WT1EI/mf4t3im9EMJx2EAn582dhEPR0PPEK1dMiVOs=; b=Xm3AqaAHp1fEAc4VinOowhuTM6 8QHdmH1S406BFn7+2zZ1u985NpnDLhxSOXXsCtFI+A8lanvchaNvjhCD54DRIxsiwRDb0gx+1gjJ3 bM/4jIVZN6JToSYxsjQQefSnKNcBGKYRc0s4spwXwc7/nPW9SkCxSDUx5VGmzSTgP3hWQKGONqLms rP8RbQaURF9wpmQzFmAVYqa5HPE32QCsqER4K+pq/JCvTrwfs9ZbSzKgqQX6xA4jCPWjsXEjF6WN6 dnXitCTg0e2kQuONG1fmxSwE2aYRnb06zFEBZ/WlRg5To5xEMX0ByIVIrpAWl8XN8QaEIA5+BD5v9 3hZe7Y5Q==; Received: from [177.139.21.57] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tWLFt-00E827-Iz; Fri, 10 Jan 2025 21:05:18 +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 1/4] futex: Drop ROBUST_LIST_LIMIT Date: Fri, 10 Jan 2025 17:05:05 -0300 Message-ID: <20250110200508.353290-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110200508.353290-1-andrealmeid@igalia.com> References: <20250110200508.353290-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 13903a278b71..4d2cd97a6ce5 100644 --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -189,8 +189,7 @@ struct robust_list2_entry { #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 f8962bc27c90..772c26901ec6 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -779,7 +779,7 @@ static void exit_robust_list64(struct task_struct *curr, struct robust_list_head __user *head) { 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_list64(struct task_struct *cu= rr, } 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.47.1