Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1643926rdb; Thu, 25 Jan 2024 01:40:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6Y3uxOBt6f6qCeUZCPSuLbg3y1CfkmI6UNLnDpKyvJkSEnEFLiJZjJwbO+E2NHfj8+1NW X-Received: by 2002:a05:6830:1453:b0:6dd:e0d0:b5ec with SMTP id w19-20020a056830145300b006dde0d0b5ecmr675074otp.24.1706175659101; Thu, 25 Jan 2024 01:40:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706175659; cv=pass; d=google.com; s=arc-20160816; b=zO31W6uaIdrWWmWjgDy1hRmmqOUaROm9ft5c1ZK4Tc3ESRm87fKN8A1JPyP6i6ZHtI zgZKE4E5tPTWrZgCAI5n6V1/ZlM93oZ4qZ+FPyba+wTJyGTMReyrNeJQ7d21AcnxSStC 1aDZRtTfjkyr58K1BLfCNRZN/CdljORIMNRbW3OhU7KKPekCG3xI005w2x7ZZ3WrgtG4 ZIWV/uvniGmujRSoNtIBfI7wipFP7pQX5M9UbOSAQVLnaSRs8Z6Slbkb9tvY1oDYYR28 Ov3ZMeDXuR2i0WIqoP0mBOrBUdi0+Tc8FZH0BG0TB+I5sa28xPLY7r24ff92yg8wx2m+ Glgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=WXpA01mh+uoqFSOs4uTrSuWJ4K282ZLZOddu5UiLmkI=; fh=9+Ax5J86nmOIjJs0GdjDWC87G7mRyWqCMrk0eKOUAsQ=; b=kFKLqSwDWqETd1tBdY3PlstPE3u6oM2rOxjSxgCktBLeF0woXVEO2Rck3a5PVb/0If pmezkC0BHkx2Un6s1PHIAs30vaxLqpUbzYeZOxY6iiaRhnNDSMmumNyBwNu9sZoAtMqk 20gc8KgHVh2k1yxM/QhsIcUJAUUhueq0OOzzqaSpP7Os+NFxQ8KXMv4K3nHY5WDL36/p tyoN0zgd4FQv7E0guF3+xOtdDRMRhm3cJ3VIF8zYk29xgxHAzRviAipKvJyT/1P4gRGs p8VVvNO2s/Rfu7KwzbtvwxQ4jH0EL0jPIz8ZOCoLHgosfmsXpekM+pWTmKT7ao68VFAT Q2oA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KFbLaFf+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-38276-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z7-20020a636507000000b005d2b7aaf9dbsi4518685pgb.790.2024.01.25.01.40.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 01:40:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38276-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KFbLaFf+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-38276-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C592D2819F6 for ; Thu, 25 Jan 2024 09:35:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEB102031F; Thu, 25 Jan 2024 09:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KFbLaFf+" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49A74200C7; Thu, 25 Jan 2024 09:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706175183; cv=none; b=PcjP/Ey6Bp7Qex8qk5QewE7sAe+NBgyTQeQtrar77vfeRHUdMunTP/p/JPiJimmlG3qFc+3S1Al926ikE8VTp1ESVpsbhCTY+AMn5x1bxYMQaC9L162HoC7DSEsOs9CzvysPAzN9+k3co5NdJviZcOT2kS7tS7C9T9EuXqW1mJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706175183; c=relaxed/simple; bh=x5hqVLU8CoA4s0xQoY88RQhPoRuUkCm6lyBsX2EB/Gw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ba6Zoz295wO5g9XzL7rUee9R64JHFKbCY8VhsKRHaGR7XDSXqNE+WY4rGxBw7L21Wa3fyagbRkfdEHzUiUV61DaJwwNwtHY58jv5FDna8WBJA3Y3AaPQ49Cs35klxYEodfQbldXyzMtlZGDhqpIe0f7R4Yyqtghp16fMuodFt3Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KFbLaFf+; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5100cb238bcso3642204e87.3; Thu, 25 Jan 2024 01:33:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706175179; x=1706779979; darn=vger.kernel.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=KFbLaFf+LCPumyRb7GgHquV958M7oNqgKvNBBc8p7zQQGPlPwOQ4Lu3f1+ayv8hhfO MCB1IaZ5SKbOKOluRQ+Qix44I8d/qHZaNj2aTa7jNBIrm5wH0DzytsNMO+F2gJxnk72c Y4IrO4z1GAYPbt1FyKmMackEZReOcehv8J6gqrc3l6oY6CFG9BFmLNkPzogVuNHD24UF 5+IYmDDe37XtpKya1BeL9QVd/RURZexH/x5pGxCfFlhgxRe6vIZy85EURLZNMFhnDpDd fT/xn4Yvf1lyrZSIapRqWJteM4Tq1M0lapEfF+kWD/5ZnjRE0gOwFg1H0+KZyLlYJWpF Yy1Q== 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=S/A5i7mvLAUggi1X9f/lU5GIP8M+rY6dRx7LwqlTBqh05FqqPWsP9tKuAdsCzAGfDp ++0tvhQqAF+fcPvui6TSk2IiIELZtfNGw0WEHHGfYWUihAMdXnmpa2MyHqGKoSJdzH8z 9vORoU/sX0LaC2w4Z2OhI5ILU5zXTQNtaMKT6L8LeRmTP877l3BqOdJfIPqCW5hmLecg yhdrZ9yUsA46B0YfQWoWNaaWvAIS3T3d1N9DdiG+o24GsD81LwbHkGROopohfsWUMn1y 1BpGWtypbYrFVDr7q4fMpmTJw2ujcwPQzy3XeIL3+uHmBeS/iYk0BSIzaGqcpBzXznyp PN+w== X-Gm-Message-State: AOJu0Yw6pdkVbezJdh6BbDsZ1txhCWxdbQo3IM41i7LiGOnZbH1tuZkn 0tL6C0XoEgW3RNsVAGMaFnTiTiwgvWVcfg6YR5HaD8OgJLbhc6QP18vFOFyVbng420NSi+el1MZ em/rG5y1WTrjYkaIPubrIz9vtjJM= 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 >