Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2990176imu; Mon, 19 Nov 2018 09:03:52 -0800 (PST) X-Google-Smtp-Source: AJdET5fY9s77vwW7HPh8doDLSCzx/sk3JRNjAkNt/PVkz/ljdIfsmCZ3ks7k9X4ef+HhnHGDhTWz X-Received: by 2002:a63:200e:: with SMTP id g14mr20874724pgg.235.1542647032766; Mon, 19 Nov 2018 09:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542647032; cv=none; d=google.com; s=arc-20160816; b=miORVXaXlciso9DuP3ElcjbWvS5p0NpVoaUC0lPYDeMECWgQ5a4X5WEy77ZuI+HMrV K48trchrOr39JB57ObBkJ9lTOY6LQ+WCB4OTIM8YZwk4MoKw25KiRa2RziLJ74n7RJxo 9sGJ6sfG1/SHVa/leKldjYRLhJxUlL/HBx5gwtrzliF7uxBKPms646Q812WEG5wcs5t7 AC9d7pON5fYouwg/nlYgNIrAlBJukpn+MoBdy/unZTNPZQn+f7Fs6yMnwDZ3ORC17h1k eKEOLmJ2e7deebZtaQaV5K9qVVFME+ohoQeYAQXiy64Qukv+VkDE2Ehjwvx262+6NK1A oBMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m+7OgYcpATu8zN3f/CDNm8KoTS5naNQmMoHYEWRXeT4=; b=WWidMn4k5MBtlsp79zzLZCmp28euNNDMPkfmhSdVbK6pxof6OTT7M9HlB/uwU7q86R nRB9Dsxa1kxR3omGFixuMJEZvM5AO5n8QLru62KvtFUfJtHSTXZBnPQfRKlF+qJAmjSI 7SQu5lajFSsb2jQ86CKQMBI9952dEwEme9/r6HnwINJC8YBzX7UO0pqrumOE+ZNPnQbb pHrI3s9+30CqcktPUSlhq/yl8CzHQJ7aYORgos52OgIL+C+rLm7ooZGwaXbuk48kS8ja 2/V7EC7dA+qbZnASL0WEN/Exd5uEsNg5VTNDrx/PHXjV9pynBrcEryaoC+I6c/VBEzGG rGpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nLjBpRuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si14616924plu.169.2018.11.19.09.03.15; Mon, 19 Nov 2018 09:03:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nLjBpRuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405906AbeKTD0e (ORCPT + 99 others); Mon, 19 Nov 2018 22:26:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:40160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405392AbeKTD0e (ORCPT ); Mon, 19 Nov 2018 22:26:34 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E969622443; Mon, 19 Nov 2018 17:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646937; bh=NNWi/CBtJ2w+gxI01j6vf06GbiabVcSn6JjtoUvVWhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nLjBpRuLIgI8QO3rsestq9JLII7be/nnHzvWlBS4XAf63b4f/QdWVfEo964V7SjVV mwGPJZ06/2VnFDshtksCuyJorV1EViF2rSLW6e5yTHsyam1ZpVIDb8p0gaFTBC1z1T voJlUQJtdnIy96BIjHINXLHB14Yx9P2k85Nh1I4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 4.4 110/160] fuse: fix blocked_waitq wakeup Date: Mon, 19 Nov 2018 17:29:09 +0100 Message-Id: <20181119162641.504370273@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162630.031306128@linuxfoundation.org> References: <20181119162630.031306128@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi commit 908a572b80f6e9577b45e81b3dfe2e22111286b8 upstream. Using waitqueue_active() is racy. Make sure we issue a wake_up() unconditionally after storing into fc->blocked. After that it's okay to optimize with waitqueue_active() since the first wake up provides the necessary barrier for all waiters, not the just the woken one. Signed-off-by: Miklos Szeredi Fixes: 3c18ef8117f0 ("fuse: optimize wake_up") Cc: # v3.10 Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -402,12 +402,19 @@ static void request_end(struct fuse_conn if (test_bit(FR_BACKGROUND, &req->flags)) { spin_lock(&fc->lock); clear_bit(FR_BACKGROUND, &req->flags); - if (fc->num_background == fc->max_background) + if (fc->num_background == fc->max_background) { fc->blocked = 0; - - /* Wake up next waiter, if any */ - if (!fc->blocked && waitqueue_active(&fc->blocked_waitq)) wake_up(&fc->blocked_waitq); + } else if (!fc->blocked) { + /* + * Wake up next waiter, if any. It's okay to use + * waitqueue_active(), as we've already synced up + * fc->blocked with waiters with the wake_up() call + * above. + */ + if (waitqueue_active(&fc->blocked_waitq)) + wake_up(&fc->blocked_waitq); + } if (fc->num_background == fc->congestion_threshold && fc->connected && fc->bdi_initialized) {