Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp866596lqh; Fri, 31 May 2024 22:53:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU02gYW5DhVJ5+ikLvLHBJ1tnvESOasq1I1cdLH3niOmnFmzY4KGw4UmihH8PodTrqrULHhRne+KZ3wT+O1FqhK21lVBfDcShRDYxmTPQ== X-Google-Smtp-Source: AGHT+IGFvP3amCJCjaNDj3HvvSm3m/kLvNfPynw0hcZA8fSE15u+92+tSsHPWbjcMJkslwQ5uwNj X-Received: by 2002:a50:ab58:0:b0:57a:4b31:5d7c with SMTP id 4fb4d7f45d1cf-57a4b3161a1mr249984a12.19.1717221230935; Fri, 31 May 2024 22:53:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717221230; cv=pass; d=google.com; s=arc-20160816; b=wZ42OoN3aWrrUTcTQSQzdVdKXg7KVKffJRY5LtXKyE86NtHdMSmDvxYRYHWsqiaWzm fROIPIE+qZmQAkj5Ihteteom5cG+fIt3Kl5UlfiFpjmjKvrsRrw/HsnP6IrB8UBl6q6l WfYw5EcAp+LYjFfsEirR70gY9LPkxrqe8OfNqHw/m+1W05RJIGSWpojpzcGQvLeLnd/q HCQdzf62SbnZy/6IHe/2mmaPl3sMgcOyNPJO5WLgrQav+JZCNAaH1BMxmJEVUjw5gxyU jwisjJ7z6keTSrdrBHH/DgAgXQ15Jb7kwQ1lxuHKAe0rhDOCqDN30uEJqqMQIoxng5fh naHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=6TOahZ1Ow/XBa1Cm/OddYBbYelxBfg1MBmWBoUYasW0=; fh=daubiDCVCULyx1cNYwX2xi9XO1xqQg1QDzhQruJQwds=; b=sPdX8zURiBWOx5pN0UYlQWwGBRtn33btpj5U9v4RbUTTNfLYLZTpucBNzDcQNXVyw2 ZAx2KwiUIyKkjywN7xo+jAl+5dGDBLqmhJg9tW0H9o0Ps9AokezSl7uR1uFW5ZVqfyUv VZ2xnuEJMlxBkWKwLopHWRZAea0Cjub5eEaYY68m0afWJq8tuEmA9G9jCtXbZpEnu6g9 dyCJ/diGRIz6mWP1c4ygSOfDRZl6AO1pCLVmN9Cq4KIoPkOCCC/PhrW+MyXHVqLS7viU +91EvaATT/h04wVOm+mHto0xqXBoZg2ytrfMrMpBAB3cWAhlFkQfGU4MSwsmfHeBBe0c KZJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-197698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197698-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a4aeee437si323215a12.13.2024.05.31.22.53.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 22:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-197698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197698-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9EAA91F24156 for ; Sat, 1 Jun 2024 05:53:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC35712B89; Sat, 1 Jun 2024 05:53:36 +0000 (UTC) Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (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 84F72111A8; Sat, 1 Jun 2024 05:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.95.11.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717221216; cv=none; b=NG4FCQvC28xuQHPhB9o/+yObNrWyQDTbuhUEWxRIE92Bnsm1Z5eHg+2u/ZGdvu34W45EuN09z9rNFo7iHbBoJ8NjuS9HwP/LE6Bkwq7Ih30cmKH8wjXKPryALf1Prf/8jEgqwETVhq7dMARWdFCr9KyQnNnE4jKd5kCfIlFgxUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717221216; c=relaxed/simple; bh=sK+PY7jfW5rGdua1lss1CPxpFyj2P5q7uLdGs1sUJpI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I1nzNO1OCc5horlZRo7K9qX1t1rYJPICSaJkMa3IS7oCysJAsZ9hitM7YBG3tnfFyvjXVQcy8FAdhR0zD/Hwba+Fj63F7uAeedkjKRPNlQWJ8rTUjGxAfEnZjGwKC9ZKs+Uchp4bGAgWgvClnXyFkjKxWbQLDFtMvB5aG+bxNQ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=pass smtp.mailfrom=lst.de; arc=none smtp.client-ip=213.95.11.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id 3643A68D17; Sat, 1 Jun 2024 07:53:23 +0200 (CEST) Date: Sat, 1 Jun 2024 07:53:23 +0200 From: Christoph Hellwig To: Nitesh Shetty Cc: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner , Jan Kara , martin.petersen@oracle.com, bvanassche@acm.org, david@fromorbit.com, hare@suse.de, damien.lemoal@opensource.wdc.com, anuj20.g@samsung.com, joshi.k@samsung.com, nitheshshetty@gmail.com, gost.dev@samsung.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, dm-devel@lists.linux.dev, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v20 01/12] block: Introduce queue limits and sysfs for copy-offload support Message-ID: <20240601055323.GB5613@lst.de> References: <20240520102033.9361-1-nj.shetty@samsung.com> <20240520102033.9361-2-nj.shetty@samsung.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=us-ascii Content-Disposition: inline In-Reply-To: <20240520102033.9361-2-nj.shetty@samsung.com> User-Agent: Mutt/1.5.17 (2007-11-01) On Mon, May 20, 2024 at 03:50:14PM +0530, Nitesh Shetty wrote: > Add device limits as sysfs entries, > - copy_max_bytes (RW) > - copy_max_hw_bytes (RO) > > Above limits help to split the copy payload in block layer. > copy_max_bytes: maximum total length of copy in single payload. > copy_max_hw_bytes: Reflects the device supported maximum limit. That's a bit of a weird way to phrase the commit log as the queue_limits are the main thing (and there are three of them as required for the scheme to work). The sysfs attributes really are just an artifact. > @@ -231,10 +237,11 @@ int blk_set_default_limits(struct queue_limits *lim) > { > /* > * Most defaults are set by capping the bounds in blk_validate_limits, > - * but max_user_discard_sectors is special and needs an explicit > - * initialization to the max value here. > + * but max_user_discard_sectors and max_user_copy_sectors are special > + * and needs an explicit initialization to the max value here. s/needs/need/ > +/* > + * blk_queue_max_copy_hw_sectors - set max sectors for a single copy payload > + * @q: the request queue for the device > + * @max_copy_sectors: maximum number of sectors to copy > + */ > +void blk_queue_max_copy_hw_sectors(struct request_queue *q, > + unsigned int max_copy_sectors) > +{ > + struct queue_limits *lim = &q->limits; > + > + if (max_copy_sectors > (BLK_COPY_MAX_BYTES >> SECTOR_SHIFT)) > + max_copy_sectors = BLK_COPY_MAX_BYTES >> SECTOR_SHIFT; > + > + lim->max_copy_hw_sectors = max_copy_sectors; > + lim->max_copy_sectors = > + min(max_copy_sectors, lim->max_user_copy_sectors); > +} > +EXPORT_SYMBOL_GPL(blk_queue_max_copy_hw_sectors); Please don't add new blk_queue_* helpers, everything should go through the atomic queue limits API now. Also capping the hardware limit here looks odd. > + if (max_copy_bytes & (queue_logical_block_size(q) - 1)) > + return -EINVAL; This should probably go into blk_validate_limits and just round down. Also most block limits are in kb. Not that I really know why we are doing that, but is there a good reason to deviate from that scheme?