Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1082184yba; Sun, 31 Mar 2019 22:13:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoy1oUrlXd+9EbWMJpngYbqCH6wbxQqIbJQTz6GBJJUb6ZSx8WNOTbCSaLE3G8E1RetUnc X-Received: by 2002:a63:b52:: with SMTP id a18mr59469262pgl.393.1554095632322; Sun, 31 Mar 2019 22:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554095632; cv=none; d=google.com; s=arc-20160816; b=St+VYjQVpbek9Zk5gkrdDImXC1SlHMaMd6cXsrZNrxS8AORC0k+XfgoexgfI/t9Xz3 f+6V225wZ/UByjafiA0dsKRYSzAmxk1lOiAALFITCimWFuzk9TLeg6CvYEOXz32nATqP n1bYlchOXIw08jZHARjV+lhQKD96H1qYOfI0KIoj+6OfH2a0dgKlnQHf+Y7DjLSLXf3Q IbQBWAaREMenlJbjAmqP7LFBlCEOyZfRi5m/aiP7TGuG7A1K96na2ZBAPDpQ1RMJ4mE3 iMi+Cu2S0TUUPY3/hcL/Dg2q3SDjmNMBCxratLElpl5+7Gfcz+nDHxXSR1Up2i6WBDNF V5Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+cAc0h7Cr6EXSojJ3+fiLuczq7pYoYHfvgCCt0G/SJk=; b=d6btKugNNsULFx1tdPwehUSJtQ2/OR+uo/zYDXfPOxl0shDObPsJhZRB3JXD/ML00Y GO6bwhmF7M4UXrBT5HcckBvP9Ifm4FR64rzahIj7rd1Cc9evqn3od+M7biP9laPZmR0w a0yqaN1dDsuGsX5/dX4bHE9mQ2VZgQz4PnzTRAwgpE9OF4h6RO0xtUoVGqUbjqSfcZUi hLr595Ng2zx3S4ygOpjUm9zWJ+1YSFcrX0nzBSWSSBFPtcg6a0PFSqk1BlWnCw+rHtPP D1d41XpjBr8njz864SDEdrqaQn1MhPYpBmlKeEQRRG7gTD82u7ZX4gbcYv9YfN4wWOAZ 26hA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si7756128plq.328.2019.03.31.22.13.34; Sun, 31 Mar 2019 22:13:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728109AbfDAFMo (ORCPT + 99 others); Mon, 1 Apr 2019 01:12:44 -0400 Received: from ipmail03.adl6.internode.on.net ([150.101.137.143]:47594 "EHLO ipmail03.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbfDAFMo (ORCPT ); Mon, 1 Apr 2019 01:12:44 -0400 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail03.adl6.internode.on.net with ESMTP; 01 Apr 2019 15:42:41 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1hApFP-0004NU-HU; Mon, 01 Apr 2019 16:12:39 +1100 Date: Mon, 1 Apr 2019 16:12:39 +1100 From: Dave Chinner To: Kanchan Joshi Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, axboe@fb.com, prakash.v@samsung.com, anshul@samsung.com, joshiiitr@gmail.com Subject: Re: [PATCH v3 6/7] fs: introduce write-hint start point for in-kernel hints Message-ID: <20190401051239.GP26298@dastard> References: <1553846032-4451-1-git-send-email-joshi.k@samsung.com> <1553846032-4451-7-git-send-email-joshi.k@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1553846032-4451-7-git-send-email-joshi.k@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 29, 2019 at 01:23:51PM +0530, Kanchan Joshi wrote: > kernel-mode components can define own write-hints using > "WRITE_LIFE_KERN_MIN" as base. > > Signed-off-by: Kanchan Joshi > --- > include/linux/fs.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 29d8e2c..6a2673e 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -291,6 +291,8 @@ enum rw_hint { > WRITE_LIFE_MEDIUM = RWH_WRITE_LIFE_MEDIUM, > WRITE_LIFE_LONG = RWH_WRITE_LIFE_LONG, > WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, > +/* Kernel should use write-hint starting from this */ > + WRITE_LIFE_KERN_MIN, Which means that when a new userspace hint is defined, all the kernel hints change numbers and, AIUI, that changes how the kernel hints are mapped to the underlying device. The kernel hints need to be mapped to the highest supported number a work down, while userspace starts at the lowest and works up. The "kernel to device stream id" needs to translate the kernel hints down to the upper range of the device hints. I think the mapping range the code uses should be: HINT Type device 0 USER 0 0 1 USER 1 1 ...... n USER MAX n {n,65535-m} UNUSED {n,dev_max-m} 65535 - m KERN_MIN, dev_max - m ...... 65532 KERN 3 dev_max - 3 65533 KERN 2 dev_max - 2 65534 KERN 1 dev_max - 1 65535 KERN 0 dev_max i.e. if you look at the mapping as a signed short, >= 0 are user hints, < 0 are kernel hints. This provides an obvious, simple way to map the kernel hints to the upper range of the device hint range. It also provides a simple way to compress both user and kernel hints into a limited device hint range - kernel always uses the top device hint, user is limited to the rest of the range.... This means the ranges don't overlap or change at either the code or the device level as we add more user and kernel hint channels in the future. Cheers, Dave. -- Dave Chinner david@fromorbit.com