From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F33D0C48260 for ; Thu, 25 Jan 2024 09:33:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F48C6B0081; Thu, 25 Jan 2024 04:33:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 57CE86B0083; Thu, 25 Jan 2024 04:33:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F64A6B00A4; Thu, 25 Jan 2024 04:33:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2699E6B0081 for ; Thu, 25 Jan 2024 04:33:03 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E1587803CC for ; Thu, 25 Jan 2024 09:33:02 +0000 (UTC) X-FDA: 81717319404.29.3A23728 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by imf03.hostedemail.com (Postfix) with ESMTP id 155142000C for ; Thu, 25 Jan 2024 09:33:00 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BUgvnqcy; spf=pass (imf03.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.167.52 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706175181; a=rsa-sha256; cv=none; b=ek2eUACTjBXHRO9r1Ba4puE8rtB+XgM6vZZjB79NpCgojCJZ5fs2su/G03GkzCWlBAP1tn nfAM68xWndKrKdJ2v9lAtl0y5Md6dmex0Ix9saO8qZbxgfbQvhaqVTb8FuiUusCa2zRynR 9BDokXbMHC6uB5ag602EGKQ9hW4H6a8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BUgvnqcy; spf=pass (imf03.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.167.52 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706175181; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WXpA01mh+uoqFSOs4uTrSuWJ4K282ZLZOddu5UiLmkI=; b=GjBRIqoVRB5K0gFHbfZzRTkk9YA05bIfolr9+M2kE2MBaVKHODmzJP9fkecKskdDJDSFqQ GPQTY109Ts318ZpsCNviqvwIgIUP4CSOzK3SvqgmKGE7P0CbNlf4gQlAV5yFHWqwbnC0H5 K10ueEED5rryO61XwaGp+OYolH3mI3M= Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-50e7af5f618so7421802e87.1 for ; Thu, 25 Jan 2024 01:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706175179; x=1706779979; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WXpA01mh+uoqFSOs4uTrSuWJ4K282ZLZOddu5UiLmkI=; b=BUgvnqcykur1gkjyAKQILjSvHZNs4nPOoY33GBBjNCWBpRcps0jfJ4sKZbsHD4p2Vq dZa/xhlWM5keMiX3gGLIUN9y4pIuTmMmeHtA6woqM9J14/57FezX29GBgGOyzQFNajSN qmtZF1qdGbFtiuub8JvKsip+b9zsyUNGceHSAvbbLdDL8lplenfROl92ED3MO3Mqsvq+ MTQyPdkhELlo0mfzSOwxl9MTodFaLkLgpIld7SPPyDDx5PtqE9ElEAmBbDjEUXE9BNmL i+IjFJqw08SZxbBwoXpq3t+OBY4p48GVh+FaRW8OjU/p0xqUQDuNNyLUQNCjz9i9jVMV EwTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706175179; x=1706779979; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WXpA01mh+uoqFSOs4uTrSuWJ4K282ZLZOddu5UiLmkI=; b=NhLIOI7IoB+5Y0bnU7DfkT8LWlYLDOqr6FfXeqF9fc8m2q7phcWRYwxfgY0Bqwq46o ByNjBzxnRBjPdEw2pdG2XLtV6wcuBhdaPYiRYuy4kc0wej8PEJjOkHjKHmjcZKWJFvCN lmcQwItAnPv+i+6W5dc43VQeS/dpNPilpQbCqLXxHBEgFtyhFWAVgfGA8lmur0gYoKEX vY2pbcH/3F10uT9mlGp15sLXqES0S5bTPi0yDoPgPAyaV1d1T3kz8PQ6fNeLBpXY9IMO gvaWRRpGf5X05MU11yWSIrr7dWpzk3G7FQYJj6DhiAuP5b0SUZFmIWj2/D3jN6Lgc2lZ y2rQ== X-Gm-Message-State: AOJu0YzX94VkugpUSSVWrRqPoin96bZ+AUkpMGPKh2KwywaXVwh6jlug lWfwh6flthAahsrCLlPgqkwEt45g/XOjKET4s2AptokgGcNYHOE1jBfYhAR9NYFLlUXdNxiGKB/ UwLi+R3ku4x/v2PimEQPZkQylNdU= X-Google-Smtp-Source: AGHT+IEpAN37g8lQLWY17BHVRMY5kv2VlCPoXzDwLx7v6JaIe9FJuFcnMcVKK5aAhAryJtEYCMvqwl5apgN50iGJRsM= X-Received: by 2002:a19:6554:0:b0:50e:aa1e:d994 with SMTP id c20-20020a196554000000b0050eaa1ed994mr305289lfj.91.1706175179064; Thu, 25 Jan 2024 01:32:59 -0800 (PST) MIME-Version: 1.0 References: <20240125071901.3223188-1-zhaoyang.huang@unisoc.com> <6b2d5694-f802-43a4-a0fd-1c8e34f8e69a@kernel.org> <95082224-a61d-4f4b-bc96-1beea8aa93a9@kernel.org> In-Reply-To: <95082224-a61d-4f4b-bc96-1beea8aa93a9@kernel.org> From: Zhaoyang Huang Date: Thu, 25 Jan 2024 17:32:47 +0800 Message-ID: Subject: Re: [PATCHv3 1/1] block: introduce content activity based ioprio To: Damien Le Moal Cc: "zhaoyang.huang" , Andrew Morton , Jens Axboe , Yu Zhao , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 155142000C X-Stat-Signature: wzppi98eaow4qdwyxa3kuxr9fmce4958 X-Rspam-User: X-HE-Tag: 1706175180-567668 X-HE-Meta: U2FsdGVkX1+YRXtas3h4TpqshidT7g0siurpUVtrVWtWWvA5LaqkWb+PHqE614kVDJdBnEO1lbSSAtrhJGR4znXwc2xXLosTSJsJGf1PGzpO4XyVbxTsv5yTHx6xePLG4WmTNvtJlLchc0ixr1mNfrBFhNrJ6bOJW3lWOw9iu5xJUfXII7F2Xt8co8Rj/pIg2lvUFXzrQMmKSxt3R/VmqJsF52b8MHp9kp8gelLa6HZkBFK4grQpQTJ/nm/Y/yjfZIXRta32aeDXQklDjobCxsLvgAX7OCluJ/IXxgRaMNdmDNbOzqQ9K0S88YIrFu8dQLKczGFTJ8/pEGlQnlz/lTtrNk9UAaX7mkgX9oBZ0FKwl8Pa579v39ZScwVaWjsGomqEomMLpDlGetuo97wBsFU966xSyJ95qYvb9Afvg9d+OcVPJ28llUZGs+chz55X3rX34OaZY7GNq9icEkU9q09ssEnbUgItjkMUjU1UvVVCxMdDSAKGobKktS8+zhOjXbSSaFHzfsFnzL+ttnxhH7e5kLoZupKIEVEiiESQoTZZsK+61YhaGkQEAMn4qWNk+jBoWh6EtxUcdVBv9sHmUivbsV6DgXMUrNQ1TAgQPawIsHn2gzQ2pfYP872Sz1WYE/2C6f6Ule95PirpVC0j/7T4XhRW6U/IQaJFR/jR+AfIBzFuMPDkeu/qIqxpkU2y0dJOkxiG1a4Kg9z2yoM9PPjrpEXB/A1g/ArqhWa4r98U87CfznTtSMc1WVJ0Kg7lQYM9CegMQgGh0oRprY4BC1NihNUA/gl3wy5TcfiYbmGpg+X4ep+HcgW0JLIMmpS0PBTkRuZenByOoEJmttb346KKoJPX9S3OhOBGLH04aHRh3FCZ9UNj6D3bcWgpszaEH1S9p/MMmXgaKGO0SZJvo0d15Ph9z6AS3InJ2qiXsgKHEHzcbQSXcTOcMEJ2N0XsyQeUDegTQtcbhmUdgwX jJnrfURl Vz3fDHQ0lqfXGzV9JHanIKyqEMVHGf5zJJDr15K8vedQ/3CmVzEzVmmIGf7hLQCZmIOlTOruoVX8CjdyEg5QBicBBJIK7iNek2muCs0DBjI+FuiE+cZD369TTU7okDwexj+9YPV0s7Wd55XDd3NohpMgrfBWIMhOLJJk+Eq1KbOKY4f0usUI3KPgrzazDm+wzy+o+78hLH2jObWOgrbUvtXdZ0jL1HGLRKd/4mdupdfnkwedbmBO3pycJIn3wDc6WOUAU+ry6NcReOta2Jag2eWMAV9trQN9W7o5kQX5TUCGmNVa6FwDL5kwx4UnwxjX0c0y5N3bW555khMjH6P+iGRZiv/ciYTEcXCYt9EnomDKaAELkg3Ox8QjyvmtAIOWTOdXtq/tlTKdvAEjQ3PRBPu71dgsm47IErQrUG5791yLwiver3Jqm51Fra+ellz5AFVj3MLWJQVTOdBKV8lOC+mTLWQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jan 25, 2024 at 4:26=E2=80=AFPM Damien Le Moal = wrote: > > On 1/25/24 16:52, Zhaoyang Huang wrote: > > On Thu, Jan 25, 2024 at 3:40=E2=80=AFPM Damien Le Moal wrote: > >> > >> On 1/25/24 16:19, zhaoyang.huang wrote: > >>> From: Zhaoyang Huang > >>> > >>> Currently, request's ioprio are set via task's schedule priority(when= no > >>> blkcg configured), which has high priority tasks possess the privileg= e on > >>> both of CPU and IO scheduling. > >>> This commit works as a hint of original policy by promoting the reque= st ioprio > >>> based on the page/folio's activity. The original idea comes from LRU_= GEN > >>> which provides more precised folio activity than before. This commit = try > >>> to adjust the request's ioprio when certain part of its folios are ho= t, > >>> which indicate that this request carry important contents and need be > >>> scheduled ealier. > >>> > >>> This commit is verified on a v6.6 6GB RAM android14 system via 4 test= cases > >>> by changing the bio_add_page/folio API in ext4 and f2fs. > >> > >> And as mentioned already by Chrisoph and Jens, why don't you just simp= ly set > >> bio->bi_ioprio to the value you want before calling submit_bio() in th= ese file > >> systems ? Why all the hacking of the priority code for that ? That is = not > >> justified at all. > >> > >> Furthermore, the activity things reduces the ioprio hint bits to the b= are > >> minimum 3 bits necessary for command duration limits. Not great. But i= f you > >> simply set the prio class based on your activity algorithm, you do not= need to > >> change all that. > > That is because bio->io_prio changes during bio grows with adding > > different activity pages in. I have to wrap these into an API which > > has both of fs and block be transparent to the process. > > Pages are not added to BIOs on the fly. The FS does bio_add_page() or sim= ilar > (it can be a get user pages for direct IOs) and then calls bio_submit(). = Between > these 2, you can set your IO priority according to how many pages you hav= e. Please correct me if I am wrong. So you suggest iterating the request->bios->bvecs(pages) before final submit_bio? Is it too costly and introduces too many modifications on each fs. > > You can even likely do all of this based on the iocb (and use iocb->ki_io= prio to > set the prio), so before one starts allocating and setting up BIOs to pro= cess > the user IO. Actually, the activity information comes from page's history (recorded at page cache's slot) instead of user space in step(1) and can be associate with bio in step(2) or iterate the bio in step(3) page fault \ (1) (2) (3) allocate_pages=3D=3D>add_page_to_page_cache(get activity information)=3D=3D>xxx_readpage=3D=3D>bio_add_page=3D=3D>submit_bi= o vfs read/write / > > -- > Damien Le Moal > Western Digital Research >