From patchwork Wed May 31 23:24:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Segall X-Patchwork-Id: 13262854 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C200C7EE23 for ; Wed, 31 May 2023 23:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbjEaXYY (ORCPT ); Wed, 31 May 2023 19:24:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjEaXYX (ORCPT ); Wed, 31 May 2023 19:24:23 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3808798 for ; Wed, 31 May 2023 16:24:22 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b025aaeddbso32955ad.1 for ; Wed, 31 May 2023 16:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685575461; x=1688167461; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=//XmFHkVZeMqVlzDIiq/XgAHXTXCaE3pApcXQx7fg54=; b=KljlptW6Z04+/MrR85fn54p+Dp+SZj+SLehmefgTM3k6ENFld4XBXpdmhCzp7uH+n5 3mhupxEX/4VQMvBu3FuJIo/8m4k137lExCakL6Dil74fDAtlQx/gfkiwsesHfO0rTdQc 8djhVBO9FEFXl0b+TXUxyp9bPpr/oBuTWgqtw74w+iJxjCs0PJtbY4ImNZtPRAcFcAqg LWIMPzIbQuQpHhrGrF0VnsmrsEmHzF9UQ/CfdZHQV5NE6aL5eKMv3VIgdboL0Jr7zTRw OjhaaKrjFGqhAms20DJsNe5D1FvQt4oB3emV00NC9oKDEJcUokY1MdDu7xRk8v2FQQiu zpmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685575461; x=1688167461; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=//XmFHkVZeMqVlzDIiq/XgAHXTXCaE3pApcXQx7fg54=; b=h+KTtyJAgZrjNCwN4dGgl8Thyn6lMxOoTpLaOG0bMg3CDNv3WxeJA3rt4l4pLo+jnW /tWoKcfhx9rA639fEAHNW7dRbNFtS3uTG5vSqnTmtcyGkLbxrFG0OtG+UJVxIIXQgvbA C5xjGJs19zzOT96vwtCKpXJt0Dh/+m/3MnVkWV+AdWx55z/vxF4AXU/vTqUTWlU/eOhS Jj9Hp/mHlYuR1bEJibUaAhiTGjx8RCMiOog/7GYKT6wvpiSO7zIX8lVR6sDm/ZbjTm7n ucfkoNBR8K3DhIL2YMqfI2aOc3nq62wxCj/kUzHR9Nxf2tANlz4h6Zg9uIxKGyH9eO+n hXwQ== X-Gm-Message-State: AC+VfDx3oUigNARg8S6iEOSadb1L2RbTk79ZLiE4Hh98Jkcx0hU7sn/c yxLgahVOCUaUWLgFPqCkl3Rxtw== X-Google-Smtp-Source: ACHHUZ601px8x8ARrLMc2iXSlf6DDgVgdz1nPF0ZJ45XeK3AvHQxFABh95TtLog/24oW6ARNxcLIxA== X-Received: by 2002:a17:902:e54e:b0:1b0:4a2:5920 with SMTP id n14-20020a170902e54e00b001b004a25920mr26191plf.19.1685575461555; Wed, 31 May 2023 16:24:21 -0700 (PDT) Received: from bsegall-glaptop.localhost (c-73-158-249-138.hsd1.ca.comcast.net. [73.158.249.138]) by smtp.gmail.com with ESMTPSA id y19-20020a170902b49300b001ac5b0a959bsm1948642plr.24.2023.05.31.16.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 16:24:21 -0700 (PDT) From: Benjamin Segall To: Andrew Morton Cc: Christian Brauner , Eric Biggers , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] epoll: ep_autoremove_wake_function should use list_del_init_careful References: <20230531015748.GB1648@quark.localdomain> <20230531-zupacken-laute-22564cd952f7@brauner> <20230531152635.e8bb796bee235977c141138c@linux-foundation.org> Date: Wed, 31 May 2023 16:24:20 -0700 In-Reply-To: <20230531152635.e8bb796bee235977c141138c@linux-foundation.org> (Andrew Morton's message of "Wed, 31 May 2023 15:26:35 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org autoremove_wake_function uses list_del_init_careful, so should epoll's more aggressive variant. It only doesn't because it was copied from an older wait.c rather than the most recent. Fixes: a16ceb139610 ("epoll: autoremove wakers even more aggressively") Signed-off-by: Ben Segall Cc: stable@vger.kernel.org Change-Id: Icca05359250297f091779c9dcf4fefea92ee8c93 --- fs/eventpoll.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 980483455cc09..266d45c7685b4 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1803,11 +1803,15 @@ static struct timespec64 *ep_timeout_to_timespec(struct timespec64 *to, long ms) static int ep_autoremove_wake_function(struct wait_queue_entry *wq_entry, unsigned int mode, int sync, void *key) { int ret = default_wake_function(wq_entry, mode, sync, key); - list_del_init(&wq_entry->entry); + /* + * Pairs with list_empty_careful in ep_poll, and ensures future loop + * iterations see the cause of this wakeup. + */ + list_del_init_careful(&wq_entry->entry); return ret; } /** * ep_poll - Retrieves ready events, and delivers them to the caller-supplied