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: 101623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp781468rwl; Wed, 31 May 2023 16:58:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YN9bL6GwBT+8oNA91PtLrgwWrZ7X5w1Mg3OxOP+PnBh7tf27MR1pTmRjxgVW7D9C7quxr X-Received: by 2002:a05:6808:3942:b0:398:57fa:9b23 with SMTP id en2-20020a056808394200b0039857fa9b23mr5385084oib.0.1685577479925; Wed, 31 May 2023 16:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685577479; cv=none; d=google.com; s=arc-20160816; b=mYDw5cndYov1J2MjHIqjAQybxTH4MORR+K5rd12Xi3LmxDMmDAdL7P06AcI/JvxJjB Ii8d5ZVBC8rvWtViohLNHVMV20/jjlsGCNqfKiX2otSmdazS7IRewEmMRXxRL5ciFmny RWW76bF3mquPdD+khlBiJnTDI4jHe90YFWViR90z6/CJehBLQlkXSgqwcRLi07XgmPTq oo2MFyZ/YslbQwI7wuTM6wa+KQaBiRoB074Uf0fGno9suIXoMud7reS5J6PJmuHd8Z4r Z19QUbGLsK/zAzCBjNgoZ+2T2SqqoZ4pHAAUVguqrwYkSxO0MBwckm1iQuWjnPgX/zmF dXiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=//XmFHkVZeMqVlzDIiq/XgAHXTXCaE3pApcXQx7fg54=; b=aJyqRufk+Eg4PTZ1FVTZ+76etF6BnNY8q/7QSDz8CX0phzwaK3o95G1RWUxxxW4ccX 0XoWSTgNC05aXv2BHohcwyInupQ3KFOm99EGPKcnw/FezwZLJg5PbnnS58tAI/ZfGyFG Z1f+BSCgyz9ditm+M0iuJPWJDMJbmV0T6KtyvSN07MlNme+qTvvL0FdoTidyYcih1YCP /uok1tbUL4uCEiEwHfj9srX77ormY4vGVLxdLQEcc94VguImY7Hege8KOp5S7Wwom1aD DECRp51G+5ALV8PFbz9dLHXYimoquInYZw86JlN+kWJ3D4PNTXsF3RhK4anREXKnv4RB CUfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=KljlptW6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf11-20020a17090b1d8b00b002565931f7c0si141632pjb.127.2023.05.31.16.57.45; Wed, 31 May 2023 16:57:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=KljlptW6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbjEaXYZ (ORCPT + 99 others); Wed, 31 May 2023 19:24:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjEaXYX (ORCPT ); Wed, 31 May 2023 19:24:23 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39DC2A0 for ; Wed, 31 May 2023 16:24:22 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1b025aaeddbso32965ad.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=HribiDLQf6pFsurEnfzgAXV8m1q847o5/i4Ol3wSFlB54aXt8fh6a14iB7N/xBSa3q 2i/U4O6yME07IQSREkTUb+TX8bcQ7v1fH2xyiX+ansirlqgWLjyH0DPtHmfmXbE9c936 zutnQPL9UZIn0EonIq6fCzl89WAs3JD+RXHLaUaR8M0q6bNxjdOKE62DfE/x9rNhwP4Y QiYxdCg1ESUd2SuGzIPx/ww2SihSvlnkI2VNshyO8ZzOd5u4YT9ZJ504/mKFtwiccuGM WUqv3W/eBNbx90naZNnrtmGOUQ2x9ATXovUnBGNNOKRS0JUC7Ht2jNVBO9cfffrNba4r T5hQ== X-Gm-Message-State: AC+VfDwjLeBo/XcfOD3oO68DDC2iN7BhEl6/trbDyHTxPFIS1boiQVQL 9FCF12IKgKg5+K2JReWg6TDS8g== 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 X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767345737870535776?= X-GMAIL-MSGID: =?utf-8?q?1767456091452974373?= 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