Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1801298imm; Tue, 22 May 2018 09:31:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZraaUWbCptuJMs6/IdZ2iURPlcTUeEvPv73GY6utVzM41pdZqTs5lLeh9kEnl7aSKG8aUTM X-Received: by 2002:a62:d97:: with SMTP id 23-v6mr25111486pfn.231.1527006679363; Tue, 22 May 2018 09:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527006679; cv=none; d=google.com; s=arc-20160816; b=QdTXkgMHy3kAW6vYDuKIveuhTGvjGuDPwMbb1bnNcC8u1Bh+MqjLdLY5CcvAMCbYIA wN6ZbVPBesJnAuA9V4tt9gvapkIlktAEfSUBcfdrqevxJ+tvYN+k5/2f4H6EyTSEQnJ4 vAuwPe3a6bQPuBPAHAidnpskQd+iweJ5UrdP/dkjBJ9V4XNKbHhnI2pPyv0O7+9XQxpG ua1qMes66M3xOH9Siq5eTlCUECX2q6KLvk1cGwjaXDVQg09bYbYGbBZog+pyFmVXaXEC Mk3/U0C9Jps5m56hOJIwSNv+L/4PnmPB9XZdvOJiROWJZpDazFV4en4OL/OXCXm71k7H R3RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=EOTuGMgIWuQ3LAzOp91ydErK+9SSofMnApoqhFq6bzw=; b=RGQurmB23odjJZdyYhiOGXXIxGb1o+iA8lCXm7cX/6ysTi7Ub/hgZqfdQ9zQ98ntcs pHcYVil6786tuMUYI+HZi2P+tg5Oy+sJxbd89p1fTfLtI0xHXG8ByR5udFeu545ihjcP dhnbSHOBvcQSHaoIywXLFeTL20AMiw8Rmdr++0tad+HjKKTvI3wSvkR2mlPiiQ4uCaKo 3OAEUrmTD7E5w8QNBJz7YcCk2Y606z9IQrqwssqR6GIfUQVFa43VZ84NtQwKu5slZHp0 stmZazcz5U0+p0YymDja05tvICx/yZ+ICq9NK6vefS4zePlYEwNqGssuw0niK/4ognmE QF2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=HBjIqY0f; 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 u189-v6si5647715pgb.247.2018.05.22.09.31.04; Tue, 22 May 2018 09:31:19 -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; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=HBjIqY0f; 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 S1751653AbeEVQan (ORCPT + 99 others); Tue, 22 May 2018 12:30:43 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:45404 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbeEVQaj (ORCPT ); Tue, 22 May 2018 12:30:39 -0400 Received: by mail-io0-f194.google.com with SMTP id c9-v6so19197967iob.12 for ; Tue, 22 May 2018 09:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=EOTuGMgIWuQ3LAzOp91ydErK+9SSofMnApoqhFq6bzw=; b=HBjIqY0f+wgVuxD3552qjBmnqOb49IuslwW3eogAquMBnSYoPCgC15NnxkuSOn69De ryKBVSlhLHZTB62fEdVdkxsbF9y10+K2sUOqMpZhavDTXhFV5JzJD4OTyRGq/dUGCVYx d4m5LtKK+jKhm6bRG9LzDRSew9d2QT/Ifb/D2YVkIzPpvEA2i/84ks18hxDc7WrLBTw+ kL0tEKqxf1A++e6hJenuyNCE8UaU9lt/Opo1n1f3p4VHLkRLCpRYHk2rzX8JQsp5Is9E c5SwB0WzuvsOIHmUhholcnQuffi6tggV5ky5Vf8WKqDt8A1+XifSTLlQha/3f4l7dYFi od+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EOTuGMgIWuQ3LAzOp91ydErK+9SSofMnApoqhFq6bzw=; b=WV8+Vmfv7QqV/ajf70YxC2qLIURIl4u30L9fGHh9NghiUVKNqjbI65OsKq8pjW+Yym OeHDoiROTzMY3JE6rQcG0HZYmXYOOYEKBad3aG+rsHC6DghAla+R9+AsdjO9NejUiFwS HEp/wslScHmg/nHEahZCOn0Xqj++uVuVzCF/kBh5P4AG9xe50+Ug5sp/7yrWtlVUAMTT nIiRzR7oI+OkuOkEqxHFZ+bbTNCCL9BrCtDxkoILuwox7jsjM58sHWLvj7R9kgkP8U2G FobozhjjTC4v1mW+SVPbHcNAkaSX30XN9zNfPOu5LojI/SkpjfA8deSFMJS2VQ0maQZs pKTA== X-Gm-Message-State: ALKqPwexskmPp2uYIUEef8UPkP1XUNj4ceQ0ZdQq6HKAmPPV7+7A4TMh asRcDMfZsySmj9NfvIrAT2EplA== X-Received: by 2002:a6b:4e19:: with SMTP id c25-v6mr16080181iob.302.1527006638986; Tue, 22 May 2018 09:30:38 -0700 (PDT) Received: from [192.168.1.167] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id r4-v6sm249904ioi.37.2018.05.22.09.30.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 09:30:37 -0700 (PDT) Subject: Re: [PATCH v6 2/5] fs: Convert kiocb rw_hint from enum to u16 To: Goldwyn Rodrigues , adam.manzanares@wdc.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, bcrl@kvack.org Cc: tglx@linutronix.de, mingo@kernel.org, pombredanne@nexb.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, bigeasy@linutronix.de, jack@suse.cz, darrick.wong@oracle.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org, hch@infradread.org, jmoyer@redhat.com References: <20180522150737.9893-1-adam.manzanares@wdc.com> <20180522150737.9893-3-adam.manzanares@wdc.com> <11fb2ee5-8352-2d35-3154-68637d99b096@kernel.dk> <084d253c-52ab-7b23-521c-28602c56153b@suse.de> From: Jens Axboe Message-ID: <58087b03-a3c7-93fd-d1ad-de77181e8806@kernel.dk> Date: Tue, 22 May 2018 10:30:36 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <084d253c-52ab-7b23-521c-28602c56153b@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/22/18 10:24 AM, Goldwyn Rodrigues wrote: > > > On 05/22/2018 10:32 AM, Jens Axboe wrote: >> On 5/22/18 9:07 AM, adam.manzanares@wdc.com wrote: >>> From: Adam Manzanares >>> >>> In order to avoid kiocb bloat for per command iopriority support, rw_hint >>> is converted from enum to a u16. Added a guard around ki_hint assignment. >>> >>> Signed-off-by: Adam Manzanares >>> Reviewed-by: Christoph Hellwig >>> --- >>> include/linux/fs.h | 13 +++++++++++-- >>> 1 file changed, 11 insertions(+), 2 deletions(-) >>> >>> diff --git a/include/linux/fs.h b/include/linux/fs.h >>> index 7f07977bdfd7..50de40dbbb85 100644 >>> --- a/include/linux/fs.h >>> +++ b/include/linux/fs.h >>> @@ -284,6 +284,8 @@ enum rw_hint { >>> WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, >>> }; >>> >>> +#define MAX_KI_HINT ((1 << 16) - 1) /* ki_hint type is u16 */ >> >> Instead of having to do this and now rely on those now being synced, >> how about something like the below. >> >> diff --git a/include/linux/fs.h b/include/linux/fs.h >> index 760d8da1b6c7..070438d0b62d 100644 >> --- a/include/linux/fs.h >> +++ b/include/linux/fs.h >> @@ -299,7 +299,7 @@ struct kiocb { >> void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); >> void *private; >> int ki_flags; >> - enum rw_hint ki_hint; >> + u16 ki_hint; >> } __randomize_layout; >> >> static inline bool is_sync_kiocb(struct kiocb *kiocb) >> @@ -1927,12 +1927,22 @@ static inline enum rw_hint file_write_hint(struct file *file) >> >> static inline int iocb_flags(struct file *file); >> >> +static inline u16 ki_hint_validate(enum rw_hint hint) >> +{ >> + typeof(((struct kiocb *)0)->ki_hint) max_hint = -1; > > This looks complex to me. Would force a reader to lookback at what > datatype ki_hint is. I'd prefer to declare it as u16 max_hint = -1, or > even the previous #define MAX_KI_HINT format is easier to read. Just a > program reading style you are comfortable with though. How is it complex? It's defining a type that'll be the same as ki_hint in the kiocb, which is _exactly_ what we care about. Any sort of other definition will rely on those two locations now being synced. The above will never break. So I strongly disagree. The above will _never_ require the reader to figure out what the type is. Any other variant will _always_ require the reader to check if they are the same. -- Jens Axboe