Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp743489rdb; Fri, 26 Jan 2024 09:16:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHknDaG4Xxu+IuWGt5Bw5iCkNcB2VIuGXxHizg6MiyZ1JHXnGyJ+k8pjWAAMivr0liysp00 X-Received: by 2002:a17:903:646:b0:1d7:88de:cff1 with SMTP id kh6-20020a170903064600b001d788decff1mr66773plb.53.1706289397428; Fri, 26 Jan 2024 09:16:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706289397; cv=pass; d=google.com; s=arc-20160816; b=gfZ0vAqvjSSIcOPlGttnVJ38TA1Z/KUi8X68t6EYH4yDhZtUVQCO685MJco0WcfVgk jC7v4KRk3SUiXXQVuZk0/+AnB3b37W2Me0pOaprCdvhNYgWwKZ79AQxgk+RhPvgOVvw8 YaeGxqWn77I9vmH4+Vps0gcFYW/My3z4KxHgwvWWl/t0H4Wu+F5ppGagdqMyySRifG6b ZpP06DPGn3Zoo9qk5bbSm5YFK4u2FxZ1Pf85z+O6aa5KV2ZBauHNY3BDwVm2AzdNPSYz RhswdIwjNhrQ0I/F2/tYTL1ETGMIEMmVODhUoOco9qG35aSVSK2iW8b1b4CrGGcvckBk dA9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Fscjw5+02nWcqj9YGEOz7mXAdbzE5tCE48cyS+dnnGE=; fh=Yt9QoqB64w2+tVNpcs8JPtFlRqKGttK98iZ0hV13oMo=; b=GepUECR7yuDoB+XUNxD8kk0ZeWEi8Xi7SKrKFT64Oyb3c1IbFuMnvyAhln7GtwQX25 yxRgayGE46HyaSzya/EAbekbqkKB50cWw6cKP7/AfxCBitWKn5EZtti1/gzFlPwQxprk VBsXeFrCorgZskPpZxKqPd4OUfdcSdL2r4u1c0ImD7LV9YErSRw2IYhKhikmRMKJ48Q4 j21Nswc1vDCLZCONZDRV7waGyvryZvyruUFhH7osNhNEg8lI1MuNJ2TDgWKM+Phg9Ynx KDu+qbhlLszLMpYjjVo0EcdhdituA1hRX/qfcHaZaeoqmCJ8tKF6Wc/TVdqV5ylxR0U0 glyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gOuwyWAt; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-39929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39929-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id jc10-20020a17090325ca00b001d72da06725si1393081plb.214.2024.01.26.09.16.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 09:16:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gOuwyWAt; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-39929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39929-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A713BB383CC for ; Fri, 26 Jan 2024 10:12:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE48C224FA; Fri, 26 Jan 2024 09:36:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gOuwyWAt" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B90A224DB; Fri, 26 Jan 2024 09:36:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706261812; cv=none; b=QXWE2/M8ysOvVcN4H5ylIm+atnoFRfzZh0e9nOY207cj1ZebNv8olV1R6COOpuyCRTRCui+7/GzVZ7BgMa2CT5bDNzn22+GCrA4ZwEA0zppm12DgtFgG+PVFRlbferSNzEf+QDJr7/cgmluXIqfXIrNNzSJK/KUjeePKrFBwCBw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706261812; c=relaxed/simple; bh=Nqs9TinaaXHwHA6044b8Z8mw+/GdCqpp7NnA+gCBoRM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LkXrXMFPXD8OUYpefDROU9fZAL3LjJJAsIq9+eG8kac48mzladCJlwBw5DsDFUKoZrig5217WQ7GQZPeTqsy4EKjrh8eGPXD1ZfN2HHGuEEnHGLJYcFLIyOaZ4LNHwcts1TzBwyhKWGoJpUIZTxYwuZcRzhxROYUmNYD2/qPyww= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=gOuwyWAt; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=Fscjw5+02nWcqj9YGEOz7mXAdbzE5tCE48cyS+dnnGE=; b=gOuwyWAtOHJYZZB8kDVsEgfvNa tzk+b/d/l2FYsERlAfsujmb8rKjohGn4n+Bjerm1Nu7gIas8kU4qd1vl82CdJSFqXa7a7TwZvpl2E OJHMXMGJ1HLGeFpsSeuP+rp+sjh7BCtodOy1dwYLVP8zU6Ulx8F3lb+AslA+ZfZ3vkVmeiJ5m8xDo leXDzaEjSp7e1eJfAjjruhDlU8oyRIKOV/IYs65et9NcfRBY7K79zrMREaTPQlZu1sVc7ZtQHWONm 1GV/jWHI8v3hXvaje41swjLKtQeaESAwcfX5HYtX0rrFvpERUrGeI4fzSiqEEBY1By36pBnx56t6t x9B7Ww9Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTIdY-0000000DBIw-3Qwx; Fri, 26 Jan 2024 09:36:36 +0000 Date: Fri, 26 Jan 2024 09:36:36 +0000 From: Matthew Wilcox To: Zhaoyang Huang Cc: "zhaoyang.huang" , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, Andrew Morton , Jens Axboe , Yu Zhao , Damien Le Moal , Niklas Cassel , "Martin K . Petersen" , Hannes Reinecke , Linus Walleij , linux-mm@kvack.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, steve.kang@unisoc.com Subject: Re: [PATCHv3 1/1] block: introduce content activity based ioprio Message-ID: References: <20240125071901.3223188-1-zhaoyang.huang@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Jan 26, 2024 at 05:28:58PM +0800, Zhaoyang Huang wrote: > On Fri, Jan 26, 2024 at 4:55 PM Matthew Wilcox wrote: > > > > On Fri, Jan 26, 2024 at 03:59:48PM +0800, Zhaoyang Huang wrote: > > > loop more mm and fs guys for more comments > > > > I agree with everything Damien said. But also ... > ok, I will find a way to solve this problem. > > > > > > +bool BIO_ADD_FOLIO(struct bio *bio, struct folio *folio, size_t len, > > > > + size_t off) > > > > You don't add any users of these functions. It's hard to assess whether > > this is the right API when there are no example users. > Actually, the code has been tested on ext4 and f2fs by patchv2 on a > v6.6 6GB android system where I get the test result posted on the > commit message. These APIs is to keep block layer clean and wrap > things up for fs. well, where's patch v2? i don't see it in my inbox. i'm not going to go hunting around the email lists for it. this is not good enough. > > why are BIO_ADD_PAGE and BIO_ADD_FOLIO so very different from each > > other? > These two API just repeat the same thing that bio_add_page and > bio_add_folio do. what? here's the patch you sent. these two functions do wildly different things: +bool BIO_ADD_FOLIO(struct bio *bio, struct folio *folio, size_t len, + size_t off) +{ + int class, level, hint, activity; + + if (len > UINT_MAX || off > UINT_MAX) + return false; + + class = IOPRIO_PRIO_CLASS(bio->bi_ioprio); + level = IOPRIO_PRIO_LEVEL(bio->bi_ioprio); + hint = IOPRIO_PRIO_HINT(bio->bi_ioprio); + activity = IOPRIO_PRIO_ACTIVITY(bio->bi_ioprio); + + activity += (bio->bi_vcnt + 1 <= IOPRIO_NR_ACTIVITY && + PageWorkingset(&folio->page)) ? 1 : 0; + if (activity >= bio->bi_vcnt / 2) + class = IOPRIO_CLASS_RT; + else if (activity >= bio->bi_vcnt / 4) + class = max(IOPRIO_PRIO_CLASS(get_current_ioprio()), IOPRIO_CLASS_BE); + + bio->bi_ioprio = IOPRIO_PRIO_VALUE_ACTIVITY(class, level, hint, activity); + + return bio_add_page(bio, &folio->page, len, off) > 0; +} + +int BIO_ADD_PAGE(struct bio *bio, struct page *page, + unsigned int len, unsigned int offset) +{ + int class, level, hint, activity; + + if (bio_add_page(bio, page, len, offset) > 0) { + class = IOPRIO_PRIO_CLASS(bio->bi_ioprio); + level = IOPRIO_PRIO_LEVEL(bio->bi_ioprio); + hint = IOPRIO_PRIO_HINT(bio->bi_ioprio); + activity = IOPRIO_PRIO_ACTIVITY(bio->bi_ioprio); + activity += (bio->bi_vcnt <= IOPRIO_NR_ACTIVITY && PageWorkingset(page)) ? 1 : 0; + bio->bi_ioprio = IOPRIO_PRIO_VALUE_ACTIVITY(class, level, hint, activity); + } + + return len; +} did you change one and forget to change the other? > These white spaces are trimmed by vim, I will change them back in next version. vim doesn't do that by default.