From patchwork Tue Jan 29 11:06:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 156971 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4523666jaa; Tue, 29 Jan 2019 03:08:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN6fZjTig9U2+GS1e1eUG4w3XyuFtSWeYzBSK1Oqpwy/zJSJjJALg8bxDWaOX2YoF+IdEDmC X-Received: by 2002:a63:6b05:: with SMTP id g5mr22667161pgc.15.1548760092777; Tue, 29 Jan 2019 03:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548760092; cv=none; d=google.com; s=arc-20160816; b=u5wcOstjnQANPOa8J8z5Si3NbdkkvemWdT5F2GUHooFS0xU6Haku7Mv2TgksC0GnjB vLFEzUzXxiUlKLRXWc18sHppnPUwoi2Wut2V/LSyR8hREQOMysUqISgtzUjbGKcruydL +J/uRwtMoNt1BY4SWBIPUOiJ1JWhHwVwGSgv3ZogNkD97Oi85iuvTOUxucNkWjoREKTN wlhZ9yf7nhTGAkwXf25xSYv4ZNj3HjmcBHFutMPki+nauNl5Ckuap5VlEOJvdAQzd7Rc f0eZ3dE4x7jA8mP2uWHkmSwifVkhy7p/kJ79bFLYNkTC9lml6/zLLrKROrebbEzk68uG l8Ow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sfh0pAFFntluWsfkKiHNCWmGd04mxXjXMAOMMF2nCLo=; b=jWbZmZ2Oqvh4pbwj8lktWx4os0pjYEQXG9U4HBepIBiTkPHBb9K/CUHXqBzTGdm7LJ WdzWV3O4qvjV2xsUOo8w3vsWQij1d0OUCM9NpU6BWbJtdsgl3fTob8Yra5w0+O1hB86B A+QFlSjM5BI8cOZQlFpfej8xstD5fzNgz2XxaDhTpFmlfKlIEsIeV+cI35w95njCe1+D Ca6ui1NBCBf//M1TxEE8y9Hes7Zsd2TW5ypRXZdXMFZm6qihLjez6LHTfh09sOuWXCU5 cp4oWcXGqg6kS8Qq85cz7hwA9XYu3HpLUqzFsfmondUKT4pIIZVve/sbXwAbbmAnbSRK G42A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bbEl1Xzg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si15859405plg.29.2019.01.29.03.08.12; Tue, 29 Jan 2019 03:08:12 -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=@linaro.org header.s=google header.b=bbEl1Xzg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727445AbfA2LHE (ORCPT + 31 others); Tue, 29 Jan 2019 06:07:04 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51794 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727176AbfA2LHC (ORCPT ); Tue, 29 Jan 2019 06:07:02 -0500 Received: by mail-wm1-f66.google.com with SMTP id b11so17358024wmj.1 for ; Tue, 29 Jan 2019 03:07:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sfh0pAFFntluWsfkKiHNCWmGd04mxXjXMAOMMF2nCLo=; b=bbEl1Xzgyv62vtDcTw804jba5WzfBOVjKpHPxC3U5g2tcPH4HKqtB+uTCqHcWc7xfx WgdKQhwnUJws1yCsxGdrqh5MOEpOUBRGDkjY7U14LxizTJ5yiae2dwFGTATB4rNJdjbr bf7Ph+MwLgcCr8DcYkS2jIlYcoixT+wlG6DFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sfh0pAFFntluWsfkKiHNCWmGd04mxXjXMAOMMF2nCLo=; b=nWK423gzkGbBoSpUVyMYeLO90vH0t3psZYSBsay9AkJpgkySj18sAaATegAP/8dMGJ J8NTAXpB4iIfWXO6rHq5bC8bKEfHJL/R85VyH+DFPJsqlkOl0FMsUoRcgK12WWo5ipCK Qtlk3isN8+N+DFphRBkNZpNKnWxD8HH2LHO7vvDvbkWqTh2ccbWznYnvPBJTMUsbw5Hn 4zWWy64xeu4K6lXxFMfJmiFqzWdv9eyXnP60WTioqxuEpSBNr7gEATtMRqGl4+++pid7 NaHNAd70MQrU1JfYFaJB4IGETk/0WPhjaCnUaSDQA+Rl2cuYwEKWPepH354PJO6hBNBn 5XmA== X-Gm-Message-State: AJcUukffD9ogsEgrYNCWSY8wTg+M2IAlQ+m5srkZw7GMEvA+9dETC8DA 3DdyxK95TkaS7UMO8ppzsLdNsw== X-Received: by 2002:a1c:8b09:: with SMTP id n9mr20820350wmd.38.1548760020924; Tue, 29 Jan 2019 03:07:00 -0800 (PST) Received: from localhost.localdomain ([88.147.67.218]) by smtp.gmail.com with ESMTPSA id s132sm2066112wmf.28.2019.01.29.03.06.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 03:07:00 -0800 (PST) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, mancha@tower-research.com, Paolo Valente Subject: [PATCH BUGFIX IMPROVEMENT 03/14] block, bfq: make sure queue budgets are not below service received Date: Tue, 29 Jan 2019 12:06:27 +0100 Message-Id: <20190129110638.12652-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129110638.12652-1-paolo.valente@linaro.org> References: <20190129110638.12652-1-paolo.valente@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With some unlucky sequences of events, the function bfq_updated_next_req updates the current budget of a bfq_queue to a lower value than the service received by the queue using such a budget. Unfortunately, if this happens, then the return value of the function bfq_bfqq_budget_left becomes inconsistent. This commit solves this problem by lower-bounding the budget computed in bfq_updated_next_req to the service currently charged to the queue. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 9ea2c4f42501..b0e8006475be 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -907,8 +907,10 @@ static void bfq_updated_next_req(struct bfq_data *bfqd, */ return; - new_budget = max_t(unsigned long, bfqq->max_budget, - bfq_serv_to_charge(next_rq, bfqq)); + new_budget = max_t(unsigned long, + max_t(unsigned long, bfqq->max_budget, + bfq_serv_to_charge(next_rq, bfqq)), + entity->service); if (entity->budget != new_budget) { entity->budget = new_budget; bfq_log_bfqq(bfqd, bfqq, "updated next rq: new budget %lu",