Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp281665iog; Wed, 15 Jun 2022 02:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfLGYa1QXWdHz+JPCpmH1tuM6SKhLmvp1G7Wl7QLVgplOAAopr1ZDVT0JzUdk3+KNjOCkn X-Received: by 2002:a05:6a00:a8b:b0:4e1:52db:9e5c with SMTP id b11-20020a056a000a8b00b004e152db9e5cmr9027422pfl.38.1655283997143; Wed, 15 Jun 2022 02:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655283997; cv=none; d=google.com; s=arc-20160816; b=KDJXF+jlCXcumCCFjGDp7m45w+OxbTI/8b0OW/FCmqziTjCFYZOxtfWZckBLF8rP/5 qpTjmZs+WqdOqK+3GVkrkv7J+tIO3P96oqsDJrt+Kunz+NbJOC5ZIMYB6iI9+NYqc036 JmK5plHn0Sy04xYy2Yksf4MbWEUb03d4tt/XGAt03d5Daby+u3L23tEwG1bqh0r9h8Xp AgAIUl3fT9Nul3EMz/+VQUE5UBD7Le2PDhbbI76LonX79FKyTrEIAAixEqEJGGnS53XX Vr664BEn9pgS9kLUUeJxC4A7QSnzWXFI785vmaERlFqRV8VCbpo+t83HC7WM3hfNI1Pf WGGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YJrquJD+yWQFne/J/19SMMhbGp5M+QEOAu37o1AhNAA=; b=iRzGKJFZnbRwgIblMr5CMLhbFWycebHZ7Qk5TA2jbPNKI8xR/S9xgStsRDvL9SYwt6 lZDMgaRP4/bAQF8CrhpPzngLruXLAK8LS65W9Gbo0acLjJNoghO65axV0i4gHvMlSyTB 0+KnKaRTcbHZE4WDPXP1ghwn0VwEVMyMglDhQ3fldGlwZc2Nt5Op/3yc165Giypug/vR e18b2o8fdAOpPS+klF1rv13mGiLBFKVjN/rn9Vwvu5qx/HNswtx86A1r5ufp+zmwh3ZU tNc8mKV0aGLsVB+GlaA0PQtBK12QdTmCRLI8lnTE46796rlLFaf3jP1b6oLU49p8KTKB Kuxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WMRSrpMO; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a654644000000b003fc2d55fef2si18471201pgr.714.2022.06.15.02.06.15; Wed, 15 Jun 2022 02:06:37 -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=@gmail.com header.s=20210112 header.b=WMRSrpMO; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346655AbiFOI67 (ORCPT + 99 others); Wed, 15 Jun 2022 04:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343824AbiFOI6h (ORCPT ); Wed, 15 Jun 2022 04:58:37 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 568491EA for ; Wed, 15 Jun 2022 01:58:36 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id i29so17881688lfp.3 for ; Wed, 15 Jun 2022 01:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YJrquJD+yWQFne/J/19SMMhbGp5M+QEOAu37o1AhNAA=; b=WMRSrpMOmpoafabiWjDDIeuA3xMWBIcaqigjlUnHATSRayX90Bqze2kjD60E30r5pd Fwf8kaAe6PmfFCDXkGlBXXncuqVUdh9oaeW3jKkaXwT0MteMTgEbt3Q7LR8xEh8NPXvp ATKAGgQUfkQM6pxE0L3R6Fvq3u8vA2naFPwU8bcCb5ByHusZmGnBgVNEqAejeyAnQZZ5 1Bqwg04omL41Lrz3qV7umt9105daiKLgCXxS8vdLTJmyJMh2e7gSetHC3MG6WNMLmmaz 4G3KJYX9XT224Y5eTfLIx12rDgjIlhU0JVahKbiUy2g9FplxWReoIdmP7pyoKXuJTust OVxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YJrquJD+yWQFne/J/19SMMhbGp5M+QEOAu37o1AhNAA=; b=XtYLGEuBoBwbVDyDyftDFLc0I7DEBRYBSFTIRLpL1p1sXuG/mT090ChzzGMUngYYu1 t6YTB6a+qJ1o6nNslhWPQRa7W7wZunwUSP1qT3MAA8Cun3pUrcBymaycR4eeTRKiRPpy whoP3FLQXiyPF2I+8XCJvDwtOTrYbOJXcIJeqEq4ER3Ju/C7pixiMOG4/c0faEae34GT eHYuL1Riq35TNlwu8RIzOeoaE3KOeGbLEpS8CnQ8EzvkOkd1EICvXB4x99rZV8V6/YIr OVUbhkhHHJA3wWMBY3F4vBgIyxorgHrd3qG/EB/THb0tuxYkhbkuKObu0bcF3zaL37CL kx/Q== X-Gm-Message-State: AJIora9/Q1T1HL/g9AKDGI8K0oIrvwWuouRYFJyYhTE8TnoIXhJ1ESJd 7kTtSj0muxwjKBfk4HsAN5CkDGYt6quFQW+cs+k= X-Received: by 2002:a05:6512:1050:b0:47d:c714:10ba with SMTP id c16-20020a056512105000b0047dc71410bamr5524327lfb.165.1655283513046; Wed, 15 Jun 2022 01:58:33 -0700 (PDT) MIME-Version: 1.0 References: <1645174105-31224-1-git-send-email-huangzhaoyang@gmail.com> <6862cdff-189e-619b-3c87-7dce6b45475f@suse.cz> In-Reply-To: <6862cdff-189e-619b-3c87-7dce6b45475f@suse.cz> From: Zhaoyang Huang Date: Wed, 15 Jun 2022 16:58:03 +0800 Message-ID: Subject: Re: [RFC PATCH] block: set bdi congested when no tag available To: Vlastimil Babka Cc: Jens Axboe , "Martin K. Petersen" , Ming Lei , Hannes Reinecke , Bart Van Assche , Zhaoyang Huang , LKML , Andrew Morton , "open list:MEMORY MANAGEMENT" , Mel Gorman Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, Mar 9, 2022 at 7:50 PM Vlastimil Babka wrote: > > On 3/9/22 08:40, Zhaoyang Huang wrote: > > From: Zhaoyang Huang > > > > In previous version, block layer will set bdi to be congested when > > get_request fail, which may throttle direct_reclaim. Move them back > > under current blk-mq design. > > Hm I thought Mel removed the direct reclaim throttling based on bdi > congestion in his series [1]. Maybe block layers has other uses (I have no > idea), for tracking congestion, that should be mentioned instead? > > [1] > https://lore.kernel.org/all/20211022144651.19914-1-mgorman@techsingularity.net/ > As my understanding, the above patch change suspending on bdi congested for a given interval to be woken up by finish of request or bio. This patch is not against above one, which add one more scenario for setting bdi as congested. > > > > Signed-off-by: Zhaoyang Huang > > --- > > block/blk-mq-tag.c | 18 +++++++++++++++++- > > include/linux/sbitmap.h | 1 + > > lib/sbitmap.c | 17 +++++++++++++++++ > > 3 files changed, 35 insertions(+), 1 deletion(-) > > > > diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c > > index 995336a..bd1e520 100644 > > --- a/block/blk-mq-tag.c > > +++ b/block/blk-mq-tag.c > > @@ -11,6 +11,7 @@ > > > > #include > > #include > > +#include > > #include "blk.h" > > #include "blk-mq.h" > > #include "blk-mq-sched.h" > > @@ -126,8 +127,11 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) > > if (tag != BLK_MQ_NO_TAG) > > goto found_tag; > > > > - if (data->flags & BLK_MQ_REQ_NOWAIT) > > + if (data->flags & BLK_MQ_REQ_NOWAIT) { > > + set_bdi_congested(data->q->disk->bdi,BLK_RW_SYNC); > > + set_bdi_congested(data->q->disk->bdi,BLK_RW_ASYNC); > > return BLK_MQ_NO_TAG; > > + } > > > > ws = bt_wait_ptr(bt, data->hctx); > > do { > > @@ -193,9 +197,21 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) > > return tag + tag_offset; > > } > > > > +static bool blk_mq_has_free_tags(struct blk_mq_tags *tags) > > +{ > > + if (!tags) > > + return true; > > + > > + return sbitmap_any_bit_clear(&tags->bitmap_tags.sb); > > +} > > + > > void blk_mq_put_tag(struct blk_mq_tags *tags, struct blk_mq_ctx *ctx, > > unsigned int tag) > > { > > + if (!blk_mq_has_free_tags(tags)) { > > + clear_bdi_congested(ctx->queue->disk->bdi, BLK_RW_SYNC); > > + clear_bdi_congested(ctx->queue->disk->bdi, BLK_RW_ASYNC); > > + } > > if (!blk_mq_tag_is_reserved(tags, tag)) { > > const int real_tag = tag - tags->nr_reserved_tags; > > > > diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h > > index 4a6ff27..30a5553 100644 > > --- a/include/linux/sbitmap.h > > +++ b/include/linux/sbitmap.h > > @@ -210,6 +210,7 @@ static inline void sbitmap_free(struct sbitmap *sb) > > * Return: true if any bit in the bitmap is set, false otherwise. > > */ > > bool sbitmap_any_bit_set(const struct sbitmap *sb); > > +bool sbitmap_any_bit_clear(const struct sbitmap *sb); > > > > #define SB_NR_TO_INDEX(sb, bitnr) ((bitnr) >> (sb)->shift) > > #define SB_NR_TO_BIT(sb, bitnr) ((bitnr) & ((1U << (sb)->shift) - 1U)) > > diff --git a/lib/sbitmap.c b/lib/sbitmap.c > > index 2709ab8..baa30d8 100644 > > --- a/lib/sbitmap.c > > +++ b/lib/sbitmap.c > > @@ -309,6 +309,23 @@ bool sbitmap_any_bit_set(const struct sbitmap *sb) > > } > > EXPORT_SYMBOL_GPL(sbitmap_any_bit_set); > > > > +bool sbitmap_any_bit_clear(const struct sbitmap *sb) > > +{ > > + unsigned int i; > > + > > + for (i = 0; i < sb->map_nr; i++) { > > + const struct sbitmap_word *word = &sb->map[i]; > > + unsigned long mask = word->word & ~word->cleared; > > + unsigned long ret; > > + > > + ret = find_first_zero_bit(&mask, word->depth); > > + if (ret < word->depth) > > + return true; > > + } > > + return false; > > +} > > +EXPORT_SYMBOL_GPL(sbitmap_any_bit_clear); > > + > > static unsigned int __sbitmap_weight(const struct sbitmap *sb, bool set) > > { > > unsigned int i, weight = 0; >