Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7462291rwb; Mon, 12 Dec 2022 15:11:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf60xSEdhFuNiQz2ic1bqxkzcXPnbdlTvMeSXR2KiRe5u8A5/P0K9E4WQuhCGIP1uRusMwJt X-Received: by 2002:a17:907:d503:b0:7c0:a99c:485c with SMTP id wb3-20020a170907d50300b007c0a99c485cmr516212ejc.68.1670886696088; Mon, 12 Dec 2022 15:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670886696; cv=none; d=google.com; s=arc-20160816; b=W1EqSCINxPAumKkA8/Foi03XBY6x8P6cHUrcalSwv8LeqCOZnszZ44Sdaf0aYo0srR HDfcF0bEJb6tGUalpeCeXGVBiu/QFDSJgrBtjJr1xrh6c/q+1024V55Z5aHMSyra0+H7 tYdKkh29ttB3ooEa5jTxSD3nDpunxTYgqcfxPlxAE8sPgsKIhXWI+DYgmFGcx3rcWbLS o0yEdjSHFUC9CdG+zsS2HFen0xrhZzhopwlYS4S5p/TZByreu/UgGD7acyU0QrLOefV9 IM2a/9q55ZnouAJ4k+8gh7d++07gX1wMvNUjXcW9rTh1zyttmfMj1RCmG3/vdQZ9rc93 fqRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=NPDIXZNKcYo1HDMoRq9WdF0H3wxdPBhSwXt2rQdX8Hk=; b=ha5YMnL9NsvQ/Ia+Ax15RaRXlcQXwsEwrYwImN1HbDZIrgjF69k11bjpTjAWak2k+M /IXR+mfVgwua0tCkKTJG/XSXaoV93jFt6Hm72o9eBme9mJmE3MGZ1D1X8rjdWLMqGWKV YRdIq5zMFzXQ2Ed4eCtNT2M/2pW2IQILnvVj8qZzFtKMkCdL4V6mCitklb8nBWI5u0/c ScQ3Nw1eBKUh/pOzaUsrOHLfpXnowSz1HXTmHXbT5ob2B2sWXK2Hj0XbbtfejDNF8d88 YeJ/wZ5QXb4vmyAMTdIn1bJlxihE1Jz2ZdxHdg05Sv0cB5j4vtSo0Kc/p8DMUnEjMqh2 nlIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=T2+mjUOn; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd42-20020a1709076e2a00b007b2912955desi7162493ejc.125.2022.12.12.15.11.18; Mon, 12 Dec 2022 15:11:36 -0800 (PST) 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=T2+mjUOn; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233852AbiLLWkm (ORCPT + 74 others); Mon, 12 Dec 2022 17:40:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233783AbiLLWkj (ORCPT ); Mon, 12 Dec 2022 17:40:39 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3B3B255; Mon, 12 Dec 2022 14:40:37 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so1638109pjd.0; Mon, 12 Dec 2022 14:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=NPDIXZNKcYo1HDMoRq9WdF0H3wxdPBhSwXt2rQdX8Hk=; b=T2+mjUOnvMC6+SflvTfeyWtuCJGJy3r5riUOCGBFfGCcjwxEGIy88D1g3qOknp/kpu r44QvUgQpK7IfygXGopoHH1Aqbi/nw2i4MQqJwBE0lCXzalcJcAW1XuiZk/FGFJxgiZw TyeR/sUnOZE0e7jeZhBYzXFCMMScwKqXqgJ8pfVbW72SncqkteKT1wIGEAox7BOx78pH 63kxkkSdWKIK4rJV+FaikdslcCef/vtpSxfob2P3xVWgugrM/WmIIqY360cPU55tMyRB cARaPspT5prnBLkezhBY9EE2WTXRTBgFrQZGgtY/jicSHR3pu+WJA3shdhCsQAysAnrt sDXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NPDIXZNKcYo1HDMoRq9WdF0H3wxdPBhSwXt2rQdX8Hk=; b=s6MzWKPNLxvCG6jYukLBeaZeHTYfKodf8YslBU1rtgv/H2hoES4w6FELyzkvgwNjyh jlQGiE73oXShZtmQ0TMfbSQPWqI3lPgsRN5/GHii/oEiAYNWAVpOE+Q6jSHYyPDL0LYy jke97veKRS8YuIZa/ufKKeLFkInfAY6EyMK3Ii8InSUfryXe+k2u/jBnp/WaJeRdt9mR lRurPM1V8Z0IFED4bofVfCoPn/njIyihWWzrKHmirR9vvl0+Bm1nCmJBct/uefsKv/Ws jFP0WpQEIlt6P6FWs6QqETdPUDv8ZerrCTg2aloAC4/BUooDfL/Se78WZQHljyeSUcce 9P4A== X-Gm-Message-State: ANoB5pnQqmv8pmwTaWhxiI39Se/ynwde9jrG/N5qwQXekHLnxt0CQY+V 9mrCT1OP6zNtXzqFJXmKlq4= X-Received: by 2002:a05:6a21:2d07:b0:9e:9685:f15e with SMTP id tw7-20020a056a212d0700b0009e9685f15emr23337003pzb.0.1670884836974; Mon, 12 Dec 2022 14:40:36 -0800 (PST) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id j28-20020a63231c000000b0047063eb4098sm5648360pgj.37.2022.12.12.14.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 14:40:36 -0800 (PST) Sender: Tejun Heo Date: Mon, 12 Dec 2022 12:40:35 -1000 From: Tejun Heo To: Jinke Han Cc: josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] blk-throtl: Introduce sync queue for write ios Message-ID: References: <20221206163826.10700-1-hanjinke.666@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221206163826.10700-1-hanjinke.666@bytedance.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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, Dec 07, 2022 at 12:38:26AM +0800, Jinke Han wrote: > From: Jinke Han > > Now we don't distinguish sync write ios from normal buffer write ios > in blk-throtl. A bio with REQ_SYNC tagged always mean it will be wait > until write completion soon after it submit. So it's reasonable for sync > io to complete as soon as possible. > > In our test, fio writes a 100g file in sequential 4k blocksize in > a container with low bps limit configured (wbps=10M). More than 1200 > ios were throttled in blk-throtl queue and the avarage throtle time > of each io is 140s. At the same time, the operation of saving a small > file by vim will be blocked amolst 140s. As a fsync will be send by vim, > the sync ios of fsync will be blocked by a huge amount of buffer write > ios ahead. This is also a priority inversion problem within one cgroup. > In the database scene, things got really bad with blk-throtle enabled > as fsync is called very often. > > This patch introduces a independent sync queue for write ios and gives > a huge priority to sync write ios. I think it's a nice respond to the > semantics of REQ_SYNC. Bios with REQ_META and REQ_PRIO gains the same > priority as they are important to fs. This may avoid some potential > priority inversion problems. I think the idea makes sense but wonder whether the implementation would be cleaner / simpler if the sq->queued[] are indexed by SYNC, ASYNC and the sync writes are queued in the sync queue together with reads. Thanks. -- tejun