Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9118275pxu; Mon, 28 Dec 2020 07:05:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQqu+zB6Ociy06xyEMQ3fI+Q1Q9iZin8FNBmrzdDrNZWXCc9x+yx8o/Kl/3Hbv267MfHyD X-Received: by 2002:a17:906:a857:: with SMTP id dx23mr42073038ejb.189.1609167956686; Mon, 28 Dec 2020 07:05:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167956; cv=none; d=google.com; s=arc-20160816; b=zoiH/GwoJSevcfQqbUTVma4HZ988Gb4A6+l1C6SAmgedLg1fMA3YDJbEjMU7phhjM9 zbbbCH0NMcsdoY+v81zVRx/QHeKqbLKkufBr3p7HOwrFTQRcKgM6yxh+ScrWvPaHTxIt jl8vi3eFUuvl5QmGzk+n/G48umOUXcFcadLHVZnYEr/b9yEOAi8EUN13ya4m+VL+C4iY msq+aqxwfLj+iwL4XZaBdRHMO59Yt9QO7TAfqzJ5JQI8X1VGp3XHszmb1MYNTmja2fdK GV2kwxThhs7CWTjYg49OmzOW+lxvZIYQMNidJdCcT4m01IvWVpJCpcWduaAJBE7LrgOA a0Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=q2nGZ24eGyG0DhVQc/RUOG4Aip8hEkseyRViYTrtpcc=; b=kAQtfOv4WfwVFsnThg36jhOMyZsRupOyvPut8GhxMZsBvAIoLMxEB6+rAN4jWbjxd4 XXrddjBcbJ9/zPmD3kdcD03PugSNCTy6ymcCJI2dhw+ELrav+VkkOE+eIIzZ/dD/Rz0F cDIpdq4ZabvJH6SUG229+iQ71JyiUUVn1NXcDk7TNnk7NFpzDEGdIPdw6wfoGH5B/i+i LzFy8qQns+VZYee9l76gDaVsJmNfe+i1ykBydpcSh6RwV1u4boPnR2UfDXtu0hMweMu+ jD70hkOP6kDyqVuIxW0FTILWxz/OqkeeQu5M829fKu48Nr8Ac0vgqW77l6akF9QYGypo /umw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KhAAIc9E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si20682005edj.459.2020.12.28.07.05.33; Mon, 28 Dec 2020 07:05:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KhAAIc9E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439415AbgL1PDo (ORCPT + 99 others); Mon, 28 Dec 2020 10:03:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:46870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439849AbgL1OMU (ORCPT ); Mon, 28 Dec 2020 09:12:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 36ED02063A; Mon, 28 Dec 2020 14:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164699; bh=14uTw111GyeL+dWcdEzV0CgjyY0Czhgw3ueJofuF2NA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhAAIc9Es94xslov9u4n/t5zx6pG7hfpjADXtDPehlxPkrqSdEvCKMh1KeflKB3IR mJzmSd52VSSO2V0IETAfTXRctYK3XjfiFhxz8IWwFsSs0+RVIDj4Lvu09Peu4AJIWb Za/TJeNIybFBiaTSMCvM2rjXoM4XT5d1A2Dn5BGQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.10 266/717] SUNRPC: rpc_wake_up() should wake up tasks in the correct order Date: Mon, 28 Dec 2020 13:44:24 +0100 Message-Id: <20201228125033.755429585@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit e4c72201b6ec3173dfe13fa2e2335a3ad78d4921 ] Currently, we wake up the tasks by priority queue ordering, which means that we ignore the batching that is supposed to help with QoS issues. Fixes: c049f8ea9a0d ("SUNRPC: Remove the bh-safe lock requirement on the rpc_wait_queue->lock") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- net/sunrpc/sched.c | 65 +++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index f06d7c315017c..cf702a5f7fe5d 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -675,6 +675,23 @@ struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *queue) } EXPORT_SYMBOL_GPL(rpc_wake_up_next); +/** + * rpc_wake_up_locked - wake up all rpc_tasks + * @queue: rpc_wait_queue on which the tasks are sleeping + * + */ +static void rpc_wake_up_locked(struct rpc_wait_queue *queue) +{ + struct rpc_task *task; + + for (;;) { + task = __rpc_find_next_queued(queue); + if (task == NULL) + break; + rpc_wake_up_task_queue_locked(queue, task); + } +} + /** * rpc_wake_up - wake up all rpc_tasks * @queue: rpc_wait_queue on which the tasks are sleeping @@ -683,25 +700,28 @@ EXPORT_SYMBOL_GPL(rpc_wake_up_next); */ void rpc_wake_up(struct rpc_wait_queue *queue) { - struct list_head *head; - spin_lock(&queue->lock); - head = &queue->tasks[queue->maxpriority]; + rpc_wake_up_locked(queue); + spin_unlock(&queue->lock); +} +EXPORT_SYMBOL_GPL(rpc_wake_up); + +/** + * rpc_wake_up_status_locked - wake up all rpc_tasks and set their status value. + * @queue: rpc_wait_queue on which the tasks are sleeping + * @status: status value to set + */ +static void rpc_wake_up_status_locked(struct rpc_wait_queue *queue, int status) +{ + struct rpc_task *task; + for (;;) { - while (!list_empty(head)) { - struct rpc_task *task; - task = list_first_entry(head, - struct rpc_task, - u.tk_wait.list); - rpc_wake_up_task_queue_locked(queue, task); - } - if (head == &queue->tasks[0]) + task = __rpc_find_next_queued(queue); + if (task == NULL) break; - head--; + rpc_wake_up_task_queue_set_status_locked(queue, task, status); } - spin_unlock(&queue->lock); } -EXPORT_SYMBOL_GPL(rpc_wake_up); /** * rpc_wake_up_status - wake up all rpc_tasks and set their status value. @@ -712,23 +732,8 @@ EXPORT_SYMBOL_GPL(rpc_wake_up); */ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status) { - struct list_head *head; - spin_lock(&queue->lock); - head = &queue->tasks[queue->maxpriority]; - for (;;) { - while (!list_empty(head)) { - struct rpc_task *task; - task = list_first_entry(head, - struct rpc_task, - u.tk_wait.list); - task->tk_status = status; - rpc_wake_up_task_queue_locked(queue, task); - } - if (head == &queue->tasks[0]) - break; - head--; - } + rpc_wake_up_status_locked(queue, status); spin_unlock(&queue->lock); } EXPORT_SYMBOL_GPL(rpc_wake_up_status); -- 2.27.0