From patchwork Thu Aug 16 16:51:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 144432 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2306075ljj; Thu, 16 Aug 2018 09:52:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzEYN712B76E5DMs1HjDcmYBIjeT8eIi2qzd+tyPcui+mlDHKWj3wIMGE/olLcvnRGkOw7Y X-Received: by 2002:a17:902:70cc:: with SMTP id l12-v6mr29928537plt.132.1534438340154; Thu, 16 Aug 2018 09:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534438340; cv=none; d=google.com; s=arc-20160816; b=Nz/Ifip8WvaSM62Yf+CPORo5OnVjYXq1OF2x6oDn+GKgPlLG/Yr6rVHwPZsXzhKb0L VKdmUDGCmHFLiW6tSHXYEDuvXUUY02h/QXY1WfV0F0RwAGIx8L2rZf2OAZ++7VJJhjM2 ejBl+kslkO9jIXk8Tei32f0TM4eZPi5yRRgn22rRgbrCx6MpUWGIMrG8EveqqGDzHV3S I9PQ7Pvx3D1ntC4Yf0hjX3OvJ6r2PGDGSKm+k9i96EP+BI8er0YshCvTeOczAbytD7iP VM7ipFbkO/fae4+WygWCRAvJcCqhMk9RT8Jrs66InnewfE5z9/qMBFTESfHSk9VVqMLI igFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gLZ7QU55IsLVhhisN3q0YJquTs5gtaPrOh82kVhuIcI=; b=P9brTCgANAmYufQAGPLRr9mg6cGgwfEhqjjvIdPJH7/ep71ydo6YKUM3oQYfaEoa8F /qkNtBGZTIa0Gxid9w6+I8D8BKFISvXbZ334DfZKCYyo2q1FWZx2KXKCgjAVimQdrJ0K ufYvOlFJwAJIwoOqakjewyckMvDJxwZtwG6B14c0Kue8S50eHZYtbHvHaN4mXmFBufAw aMtHiJfdqVLepT348LhxE1RwSJhsgnOhxHMbJUCtMX/+qy933/ObHqnj1NlcUJlCDdQF tdhmninc63A0aOTqTujf9/5jpfh35c05ocYtWWOxdZ/j2s+eo8i9uQvF1G/Ccm0MXkpG IadA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q9pA60Bv; 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 c17-v6si23533003pge.273.2018.08.16.09.52.19; Thu, 16 Aug 2018 09:52:20 -0700 (PDT) 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=Q9pA60Bv; 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 S1731133AbeHPTvi (ORCPT + 32 others); Thu, 16 Aug 2018 15:51:38 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36092 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727745AbeHPTvg (ORCPT ); Thu, 16 Aug 2018 15:51:36 -0400 Received: by mail-wm0-f68.google.com with SMTP id w24-v6so4945740wmc.1 for ; Thu, 16 Aug 2018 09:51:57 -0700 (PDT) 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; bh=gLZ7QU55IsLVhhisN3q0YJquTs5gtaPrOh82kVhuIcI=; b=Q9pA60BvtGVg5Qk9BZEC9RPwv6VE30CQG96npMXKKLFK687sa2wy5rmGfhusSXFe1y 6P4pAvKNB9K5o0+W9hW8qcfmjyx7QitMS0xwesCJ0X1vc960UZV3Rv2aPGzYPumCJQCc e9DKMRLroOeAn7gPZuXSrQ666mIhWcaGixrxk= 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; bh=gLZ7QU55IsLVhhisN3q0YJquTs5gtaPrOh82kVhuIcI=; b=USf56FvQ/fOCTnPANJ9jCK/kaE9QcvvJ3/W5rntLkNIxRVyN/uAz/1hsP8VxIjtEjT hYof6V/iWqB6FsU8iE1QyDIz+5RFWKQwUjopg4SAPlrp0HOxy4Zmh3P83MgTT5JBjFdF W1eY+vW9AfMLKJzqTe1fiaFSOEUXTVsovabyTH9P50vawGtm8UCDHs3cnIYfRmGa+/dc RVFpooDonVS9ZJKpeKtSQQC3+v7ynOQxV9O8q8EwEtmzzPkrSpjoSvQ268qfwf2xbZxl pwcNl1CRkIH5DBmBc2liUk8gkZxHG1pS2tyQkLfpoEV4skKXnjXNrclL7mdpbZFBMjGq O/BA== X-Gm-Message-State: AOUpUlGf1KM9t2pibvxXIXDeDv8VNFP10O940ItGd4s1tTuGG6eX+qE9 m63bN0A1MarpGGZ2knziiuTfmg== X-Received: by 2002:a1c:bb86:: with SMTP id l128-v6mr16316007wmf.26.1534438317067; Thu, 16 Aug 2018 09:51:57 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:51:56 -0700 (PDT) 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, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 1/4] block, bfq: readd missing reset of parent-entity service Date: Thu, 16 Aug 2018 18:51:15 +0200 Message-Id: <20180816165118.17402-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The received-service counter needs to be equal to 0 when an entity is set in service. Unfortunately, commit "block, bfq: fix service being wrongly set to zero in case of preemption" mistakenly removed the resetting of this counter for the parent entities of the bfq_queue being set in service. This commit fixes this issue by resetting service for parent entities, directly on the expiration of the in-service bfq_queue. Fixes: 9fae8dd59ff3 ("block, bfq: fix service being wrongly set to zero in case of preemption") Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) -- 2.16.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 41d9036b1822..62efc1b97afb 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -3298,6 +3298,27 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, */ } else entity->service = 0; + + /* + * Reset the received-service counter for every parent entity. + * Differently from what happens with bfqq->entity.service, + * the resetting of this counter never needs to be postponed + * for parent entities. In fact, in case bfqq may have a + * chance to go on being served using the last, partially + * consumed budget, bfqq->entity.service needs to be kept, + * because if bfqq then actually goes on being served using + * the same budget, the last value of bfqq->entity.service is + * needed to properly decrement bfqq->entity.budget by the + * portion already consumed. In contrast, it is not necessary + * to keep entity->service for parent entities too, because + * the bubble up of the new value of bfqq->entity.budget will + * make sure that the budgets of parent entities are correct, + * even in case bfqq and thus parent entities go on receiving + * service with the same budget. + */ + entity = entity->parent; + for_each_entity(entity) + entity->service = 0; } /* From patchwork Thu Aug 16 16:51:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 144429 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2305763ljj; Thu, 16 Aug 2018 09:52:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy6ZEt0Oe+s0Gq91KOULOD6khrRMYZu0iDkgcR9Ev6j74R6sMTEW0weVDxDA2Bf78Ix9tvz X-Received: by 2002:a17:902:9883:: with SMTP id s3-v6mr29764039plp.194.1534438323421; Thu, 16 Aug 2018 09:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534438323; cv=none; d=google.com; s=arc-20160816; b=tHaaTvTRI+yC+CJVRENvvrlQ72+f7bPzJ2ObZ2fcFZ1eqzCgpHB6Dt4nH6tqft5Ufi 8vI/Z+6fHEEOYVQn62vG1tPNugxaQ63SnvenrZM0VkFrVEtuST+8VuQ5KpX56qe50r0g DOiBkGvl3dZejxREyZRp2hdUFT8vUJZd+Xc6jD07I288/RW20Lta+69hRAwpBzyx6AAd N5kX665R3/dvdiJhLhjbKxKsGECv2averhXVwYfvPchSyCAF99x9oWGqpuhGotLjzhSy KGYF6v9+7eUaQ4nPGyL6vF2wtFxbYAvxT4vFCxPnzia660cott6oXbgNSD9kIMKI0uzK 0yAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3znMJbeQWkhLxICWhFJ+SqqBYPCgwq4EtBhKQqaIsps=; b=Y/vUKqwlG0GYtIQkI+U5lq6KQCcDB2P0a2ZnlFFTeImLqxAGALhUrfeRdweAkpS+Ak yCoJNs48/ua41iZPzLx70uyxfsGtCr/+FlQ4dsfFO49ooveOiUXb2ZPTPCIyEru5A6/I wN28/0Rvk/WlHPa99TLRhCfqlRUHVJqGT9FGYonkj5HfpxNzxmeaLpFv2Sz4+AzL45k/ zVHtdUmkXE5GofQrv6iSsEKmGrAUVrr9bJMN/jLvvs5wh6Ry1I6tUH4CKbzxEKlzakNh bg9KZHte/IxPw+MsliuPsd/HR25fKtoakV0KoU6dDqKt6y6DWWnjPYpGnesEH88ph5kJ fZpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qdfz2LOk; 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 97-v6si22182947plm.290.2018.08.16.09.52.03; Thu, 16 Aug 2018 09:52:03 -0700 (PDT) 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=Qdfz2LOk; 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 S1731201AbeHPTvj (ORCPT + 32 others); Thu, 16 Aug 2018 15:51:39 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37594 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730213AbeHPTvh (ORCPT ); Thu, 16 Aug 2018 15:51:37 -0400 Received: by mail-wr1-f68.google.com with SMTP id u12-v6so4756908wrr.4 for ; Thu, 16 Aug 2018 09:51:58 -0700 (PDT) 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; bh=3znMJbeQWkhLxICWhFJ+SqqBYPCgwq4EtBhKQqaIsps=; b=Qdfz2LOkYSdPyOD6TF+CsHVZ1DQJ6SPsLHaTDZx6EUtQLd23d2RMLG1E8xYieWfmi0 35/AmLoOx83QJWTN1HZ9yU5Lspwkvbq6DJRAwJThsXqJ4BVXAZfMroynE6qWHx4R8AfY gF9ziapCrvqBV2WmxW7cYVl5wifsyBlZgE750= 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; bh=3znMJbeQWkhLxICWhFJ+SqqBYPCgwq4EtBhKQqaIsps=; b=dtfH7ySeKZ/UZqjoUOjoCWE4qzuncx6g9OCBFCyTylnGQuMGJpMa//BUuK3VTOYsVf f3B0TWrgKiN/FaagnOB1eAIgVziEtCkl5RoERDPHdniPoRx7HchVLo57VVFYQUkcCy5p dZmTx95acQXMAyzq1U8bX904GOELaQ8Y1sfcTuAgMLV1mlJCcsEfdIStHfldi+VxL1dT p8GC0LktD5AsEuCWu2RQRwKwdQMNy++TTQHd+sLY5yos0xBhVRGtphqmxayPFBG0w6mK FgXTu0ETSjcfoNyNfn9i6BJ5HiAZkKR2KJnYpb04koPXAZHR1KhLP/WxKWKO+Uyks6uS DRow== X-Gm-Message-State: APzg51DxyFyYMdsTYzQnyxpDd032vwdfq3Fm3g0q0EGb2hPjwpE2ADBd uIf4jziDlc65zYLykNqzNrUODg== X-Received: by 2002:adf:ac41:: with SMTP id v59-v6mr632378wrc.7.1534438318284; Thu, 16 Aug 2018 09:51:58 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:51:57 -0700 (PDT) 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, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 2/4] block, bfq: always update the budget of an entity when needed Date: Thu, 16 Aug 2018 18:51:16 +0200 Message-Id: <20180816165118.17402-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the next child entity to serve changes for a given parent entity, the budget of that parent entity must be updated accordingly. Unfortunately, this update is not performed, by mistake, for the entities that happen to switch from having no child entity to serve, to having one child entity to serve. Signed-off-by: Paolo Valente --- block/bfq-wf2q.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.16.1 diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index dbc07b456059..d558fd26740c 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -130,10 +130,14 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd, if (!change_without_lookup) /* lookup needed */ next_in_service = bfq_lookup_next_entity(sd, expiration); - if (next_in_service) - parent_sched_may_change = !sd->next_in_service || + if (next_in_service) { + bool new_budget_triggers_change = bfq_update_parent_budget(next_in_service); + parent_sched_may_change = !sd->next_in_service || + new_budget_triggers_change; + } + sd->next_in_service = next_in_service; if (!next_in_service) From patchwork Thu Aug 16 16:51:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 144430 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2305809ljj; Thu, 16 Aug 2018 09:52:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzicrqUJbGNrR0Ndh9rUmlOLVpfr35coufkihdesfyB8WR/uojm+CmzVAiaSAkrWVasqllU X-Received: by 2002:a63:4d47:: with SMTP id n7-v6mr29720985pgl.270.1534438325547; Thu, 16 Aug 2018 09:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534438325; cv=none; d=google.com; s=arc-20160816; b=Jlxgdnb7+WbdjWrmkCG8gJCxzd42X8tfuMvy+xYzoX3N0tC3CnhnwO3rjARoVS0ZjO 3GtLqNDTTrRktFzkA7Hvud9C9uTbemL+W4TCLa/dr2OhkYPr+Fv2UVFCa++BJjLeanaa Ni4mCB6nVo5bobE9G/2YzIkV+8rD2/ilsq6Z7Z5uHAFMhkO2vhOwE5ufW64qf9mj4951 95dLFGjiCN2V4urciGK2hHWunmu0sbv80XAa+1mmf85NUH4lgfRGFR6+lH5RuuLseH5N IB5V4xsiOkrhnUxSNKlgWNJBLNUW/+rajfw9e3JdBeQT0OHGFOE5XZSq3F5vW9IL21rB VDrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pyZHAK8ZrpQtkw3weKOOEv6ell+gZqXbA4ONipLRAF4=; b=ktL3VkjsQDosdCqEQM94BiedRRW7ZsQ5MJSNQEgJd8dyBnOkqwsRRrsC6z+gjMOaXx wh+crMtxyn40UOvYlxKJpMmKt8JqrXaNmGMZCNDXiBqjvV5R5HE/Ufi2LGkbjxi7SMyV IAaBvANz4Z2uwHiXTIh4LpUri0zY9UYt7fhBH2tc/+9N+g4hwAq2Ws1ijlp1HyPqDaHb fQ1AL2Ka3X10maosVhksQS46Huqxgti3Ef/QRYFzWknH5CjgqF4gCk69Bo8jFHkJiLA+ r3EPjRFUBK5qezhvd0a+1bOOKDImV+a5DfIGpAmtnRsPDxB+FVFlUYRe8rQiI4COJSF/ gfbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hy4r/kfd"; 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 y22-v6si26354230pgj.436.2018.08.16.09.52.05; Thu, 16 Aug 2018 09:52:05 -0700 (PDT) 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="hy4r/kfd"; 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 S1731354AbeHPTvl (ORCPT + 32 others); Thu, 16 Aug 2018 15:51:41 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37595 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730555AbeHPTvj (ORCPT ); Thu, 16 Aug 2018 15:51:39 -0400 Received: by mail-wr1-f66.google.com with SMTP id u12-v6so4756971wrr.4 for ; Thu, 16 Aug 2018 09:52:00 -0700 (PDT) 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; bh=pyZHAK8ZrpQtkw3weKOOEv6ell+gZqXbA4ONipLRAF4=; b=hy4r/kfdZPm+yqODJPunTxDsg5mue4mKmETW3Vw9NOCtlXc1ialmJEye/UWWyrYrBM +Wt8A+882lWG5AQk25HH2rxZFhVQH9J59Uqn8y4uoYbxKBFdZTJbZTohU69B0HOTHqgd WxAtxKPPbusR39V4+1FZfXujWLFoT34IVbrtc= 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; bh=pyZHAK8ZrpQtkw3weKOOEv6ell+gZqXbA4ONipLRAF4=; b=C290/zrKJHHlsOY6dUH9uJlGv74ccVkWgldLyRRo1B2SboddRlk3pHQH3EDpzYO/1/ k0s2yrFa6dgBEh73rxphH2k2SvF0JB84BLcGJJfQILLQ6xUnnxcsGEAEyup0EDdOKlf6 zHROXi1bU1Gl9DxdmBNKI4G7PBtJ3w44uzC1z2plkz1azUii1nsqqaE7a29HfCbKFHb5 buKsXAXDrclP5ZuWyOqQ/ZPUvq3m0fDOvHxc4Qp0WYi2MqHOePUi+ahUQ7i9HJWiTNo0 vj6/yMPGw5U4jFSP2IszUd5bF0qkoQhO8sfU4SvhfMYNJxsU7oU4mFTp90uJUFvNbUX0 18sA== X-Gm-Message-State: AOUpUlG/KMP0JKNsc3bN7ZGaecLgiXR8hAU+HYE8X+8seG9zrQZ+Vgs9 Pj0/EV9J/ejH2D0W0nP8nJkRkg== X-Received: by 2002:a5d:51cf:: with SMTP id n15-v6mr20603741wrv.107.1534438319542; Thu, 16 Aug 2018 09:51:59 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:51:58 -0700 (PDT) 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, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 3/4] block, bfq: reduce write overcharge Date: Thu, 16 Aug 2018 18:51:17 +0200 Message-Id: <20180816165118.17402-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a sync request is dispatched, the queue that contains that request, and all the ancestor entities of that queue, are charged with the number of sectors of the request. In constrast, if the request is async, then the queue and its ancestor entities are charged with the number of sectors of the request, multiplied by an overcharge factor. This throttles the bandwidth for async I/O, w.r.t. to sync I/O, and it is done to counter the tendency of async writes to steal I/O throughput to reads. On the opposite end, the lower this parameter, the stabler I/O control, in the following respect. The lower this parameter is, the less the bandwidth enjoyed by a group decreases - when the group does writes, w.r.t. to when it does reads; - when other groups do reads, w.r.t. to when they do writes. The fixes "block, bfq: always update the budget of an entity when needed" and "block, bfq: readd missing reset of parent-entity service" improved I/O control in bfq to such an extent that it has been possible to revise this overcharge factor downwards. This commit introduces the resulting, new value. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) -- 2.16.1 diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 62efc1b97afb..653100fb719e 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -187,11 +187,25 @@ static const int bfq_stats_min_budgets = 194; static const int bfq_default_max_budget = 16 * 1024; /* - * Async to sync throughput distribution is controlled as follows: - * when an async request is served, the entity is charged the number - * of sectors of the request, multiplied by the factor below + * When a sync request is dispatched, the queue that contains that + * request, and all the ancestor entities of that queue, are charged + * with the number of sectors of the request. In constrast, if the + * request is async, then the queue and its ancestor entities are + * charged with the number of sectors of the request, multiplied by + * the factor below. This throttles the bandwidth for async I/O, + * w.r.t. to sync I/O, and it is done to counter the tendency of async + * writes to steal I/O throughput to reads. + * + * The current value of this parameter is the result of a tuning with + * several hardware and software configurations. We tried to find the + * lowest value for which writes do not cause noticeable problems to + * reads. In fact, the lower this parameter, the stabler I/O control, + * in the following respect. The lower this parameter is, the less + * the bandwidth enjoyed by a group decreases + * - when the group does writes, w.r.t. to when it does reads; + * - when other groups do reads, w.r.t. to when they do writes. */ -static const int bfq_async_charge_factor = 10; +static const int bfq_async_charge_factor = 3; /* Default timeout values, in jiffies, approximating CFQ defaults. */ const int bfq_timeout = HZ / 8; @@ -853,16 +867,7 @@ static unsigned long bfq_serv_to_charge(struct request *rq, if (bfq_bfqq_sync(bfqq) || bfqq->wr_coeff > 1) return blk_rq_sectors(rq); - /* - * If there are no weight-raised queues, then amplify service - * by just the async charge factor; otherwise amplify service - * by twice the async charge factor, to further reduce latency - * for weight-raised queues. - */ - if (bfqq->bfqd->wr_busy_queues == 0) - return blk_rq_sectors(rq) * bfq_async_charge_factor; - - return blk_rq_sectors(rq) * 2 * bfq_async_charge_factor; + return blk_rq_sectors(rq) * bfq_async_charge_factor; } /** From patchwork Thu Aug 16 16:51:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 144431 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2305901ljj; Thu, 16 Aug 2018 09:52:10 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxOFdNp/fJ0EM/dPCR40+95vQ5or/9iBUS30GLiWy6rh1SPcNYLnDuolNOH/8rjdJbwlex6 X-Received: by 2002:a63:4951:: with SMTP id y17-v6mr30227619pgk.32.1534438330773; Thu, 16 Aug 2018 09:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534438330; cv=none; d=google.com; s=arc-20160816; b=gg1eQjSBVz4yVMhk2Yc0i7ZZcNVWOjDu2+I++bXyxIXJFZUdjmfCfb6FZ6LkRYT9M7 qCbU6MhfkWHuD7d2ilmhZjAM9IrHowpSwAjSk5NogSj73ZMbF2DajFsxZwnUBnnA6WpQ uMtBAd15QNYQxVJtSeA9RyUgIoLT6aoEmDxAWfNrhbIcu9n4w4wC5iQ6+UZNIxjIL2Aa hmUgSEi7vdNy3adbikvg0ioAboaJPub5m8u7aZk7Wq8sd0vkmoPD+4ozMVMXufKNYGI9 3JJt2a6fu/N3HDpnsctTcltVXEMjoXoEnGzpftHWnJ2xrWQ0MUMBl6KA6OArP6hPGE4M yT9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=MFwx1lYhKb+srSCn4IHsLo9KuWJaInJYfQS9cQKsfGY=; b=iUOjnosciaCRWTXjbneqqeQm6IG+ffGkV9FXMTLFFvSvbaYNKQTgnZIRb+MWcpqd4A bNM4HXfc10CJmfRDccnX/wDdHLeXBqhe8hJW/vWoXFfQkIcHzWYaC8fy9LbljnaNMFGZ 9xdSDke2JlJdiKjdEHjU+0+9Tq7NAJmozkQrWDetLtINRi8FPJhxPxfHsWHLyGmtlRzG kSOgbr1agMnWVfukBm0t0KbQvXpB8U5l/E+rVeMC/EdkCJzMTS8c8IsdBhgupWoqZXBd FHflMDU8lWymb/WUSh5ni1U2pAu04F6MgnXLyNp/SuBpSvE1EKmkh5OHtW+euMbAGnN0 G0og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B0YQOoaw; 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 b8-v6si12305504plx.110.2018.08.16.09.52.10; Thu, 16 Aug 2018 09:52:10 -0700 (PDT) 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=B0YQOoaw; 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 S1731274AbeHPTvk (ORCPT + 32 others); Thu, 16 Aug 2018 15:51:40 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35749 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731207AbeHPTvj (ORCPT ); Thu, 16 Aug 2018 15:51:39 -0400 Received: by mail-wm0-f65.google.com with SMTP id o18-v6so4985504wmc.0 for ; Thu, 16 Aug 2018 09:52:01 -0700 (PDT) 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; bh=MFwx1lYhKb+srSCn4IHsLo9KuWJaInJYfQS9cQKsfGY=; b=B0YQOoawMAWJoKCm802FdEDxe+UJlMEdwCA5khaGmZ6p39K7Gw81QwN3BK6cQ4Cne9 46NGpbhJ51XNytJO+w2Guj6f4a3QM5b4DzYQ/P7Jl+3njrMM9Gl05ABT3k3fsSn5Uk0z 9RhpKol9CpwSX/CrqFTSLyfqkPiX6+u3vJhvA= 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; bh=MFwx1lYhKb+srSCn4IHsLo9KuWJaInJYfQS9cQKsfGY=; b=rN3qwnSK/ymc2Xv/W3hDSMBenIkgojngjBsVzRRcM5UDpoE+8dDQNfbbZpQoOY/wR9 +xhOcA863G3bR1RV+t/atrkkKP0zwCQsi8DXRWz3F4gm5uqpj/2vrxLJMgqW1yrRuDAH frjNwBfhUjm8f0sewp+j5cpCltIxzDLdl1MXIno/Iclqa/LzJW8cot7SEAIqGDfhz9wS osAK4MaOaKY7GSQXAo7KRWMZJ1foq+ubBb22h9yt0VjXVGpqhSyBUu0v18PZOHpywjVr Wk7dia0B25//AtI6DXTTH9CuL/KzNSUlJO3GQDnRHqhGRLPuAxEkNxAF5ziAhJptuZmM dBvw== X-Gm-Message-State: AOUpUlFhUrJc1ZvopAp0P5ZZtHlGRB+EZKdBaK12dJy/I/B+7WcHxiM5 RTDTXZjdaRyFw8zSpWRNEl6lpQ== X-Received: by 2002:a1c:9550:: with SMTP id x77-v6mr15682250wmd.135.1534438320867; Thu, 16 Aug 2018 09:52:00 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:52:00 -0700 (PDT) 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, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 4/4] block, bfq: improve code of bfq_bfqq_charge_time Date: Thu, 16 Aug 2018 18:51:18 +0200 Message-Id: <20180816165118.17402-5-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bfq_bfqq_charge_time contains some lengthy and redundant code. This commit trims and condenses that code. Signed-off-by: Paolo Valente --- block/bfq-wf2q.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) -- 2.16.1 diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index d558fd26740c..ae52bff43ce4 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -881,15 +881,11 @@ void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq, unsigned long time_ms) { struct bfq_entity *entity = &bfqq->entity; - int tot_serv_to_charge = entity->service; - unsigned int timeout_ms = jiffies_to_msecs(bfq_timeout); - - if (time_ms > 0 && time_ms < timeout_ms) - tot_serv_to_charge = - (bfqd->bfq_max_budget * time_ms) / timeout_ms; - - if (tot_serv_to_charge < entity->service) - tot_serv_to_charge = entity->service; + unsigned long timeout_ms = jiffies_to_msecs(bfq_timeout); + unsigned long bounded_time_ms = min(time_ms, timeout_ms); + int serv_to_charge_for_time = + (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms; + int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service); /* Increase budget to avoid inconsistencies */ if (tot_serv_to_charge > entity->budget)