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 X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 986C8C33CB6 for ; Sat, 18 Jan 2020 00:17:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EADD21D7D for ; Sat, 18 Jan 2020 00:17:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="piNWalyr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730434AbgARARA (ORCPT ); Fri, 17 Jan 2020 19:17:00 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36561 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730260AbgARARA (ORCPT ); Fri, 17 Jan 2020 19:17:00 -0500 Received: by mail-pf1-f193.google.com with SMTP id x184so12691341pfb.3 for ; Fri, 17 Jan 2020 16:17:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Y6hFtlGWNj2335ptBmTRWPobE2rmTBdw86gaZCZvr98=; b=piNWalyrCazeaNdOIEIExKlexZTPIGOgNqDRrIJZk+6RywU5zIJ4q2GRfg7Y6teOQy uwZfYEHYU5cpPTAaQIV9LDwHWphc7CB3f3Yb7ai8TvKyN5WRnoTsv3uXBPmYDHZKpTdU 2B+slw2na/O0P2Px0ooBbVj75eH3Yw6VPZqBxZsIWRs1uhtFArdeBxnuUc0GOlUVIVtl CQLsS0rwfaIjcA025vDbKYVrkkKckA06w4uad7Kotj9QSVEzFZcf8cyF9lryN+IOl73j ZSbTUyadOq4ClJBO0/gw4dbjk2DdPf2gWX/6DuQIMAHvvcHsfquav4FpPjBNBShRaI8g 5gkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Y6hFtlGWNj2335ptBmTRWPobE2rmTBdw86gaZCZvr98=; b=kV3FwVob00qfShuJB3+V/D6ReLYbb2C560Sl2Oke9mmiLLIDXuWjx7Cf9qhC7+CTIh txESq6Vj6NzZTYKWGeLPfitB2gK3sMX80WcbsEEbMFgvWQsXbNI85g01WylLB0GPzhSh xuJFFBb9mAXLpsCpskQTfUa+76ugDhi83siykEMnzaI+DYpcTZl+OshnXLgbuzIfk1pH odmD1jXXWJIAsiG6DaXtyeRzEBsw4AvIVbus34UyKm1qFIYS189eX/7b2tTv5vJh9Abh giC6EO/YQUJgvbdZd+SFs0TM3aDLJshlKr8OvsVNRTdBGim1sK5zRT/gz/E2em2Di5ML UbyQ== X-Gm-Message-State: APjAAAX9iNB/TmA/1PNGzl/0QajaVdth4Rfd4gA07L3lYRm9uNHrxU3t tRXurOG5GeNp1dNBMt2LMSDTU9XFizY= X-Google-Smtp-Source: APXvYqwnnCKaqiVUSOFPsMT/FPdjbdkheYjE0PvYbNDZcoQqGmEcUuiWNJKlENaWcds9yIQqVrHV+A== X-Received: by 2002:a65:4381:: with SMTP id m1mr49118391pgp.68.1579306619174; Fri, 17 Jan 2020 16:16:59 -0800 (PST) Received: from [192.168.1.188] ([66.219.217.145]) by smtp.gmail.com with ESMTPSA id n26sm31102181pgd.46.2020.01.17.16.16.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jan 2020 16:16:58 -0800 (PST) Subject: Re: [PATCH 0/2] optimise sqe-to-req flags To: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <37a04c11e980f49cb17a4fd071d2d71a291a8fd5.1579299684.git.asml.silence@gmail.com> From: Jens Axboe Message-ID: Date: Fri, 17 Jan 2020 17:16:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: 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 1/17/20 4:14 PM, Pavel Begunkov wrote: > On 18/01/2020 01:49, Jens Axboe wrote: >> On 1/17/20 3:41 PM, Pavel Begunkov wrote: >>> *lost the cover-letter, but here we go* >>> >>> The main idea is to optimise code like the following by directly >>> copying sqe flags: >>> >>> if (sqe_flags & IOSQE_IO_HARDLINK) >>> req->flags |= REQ_F_HARDLINK; >>> >>> The first patch is a minor cleanup, and the second one do the >>> trick. No functional changes. >>> >>> The other thing to consider is whether to use such flags as >>> REQ_F_LINK = IOSQE_IO_LINK, or directly use IOSQE_IO_LINK instead. >> >> I think we should keep the names separate. I think it looks fine, though >> I do wish that we could just have both in an enum and not have to do >> weird naming. We sometimes do: >> >> enum { >> __REQ_F_FOO >> }; >> >> #define REQ_F_FOO (1U << __REQ_F_FOO) >> > > I thought it will be too bulky as it needs retyping the same name many > times. Though, it solves numbering problem and is less error-prone > indeed. Let me to play with it a bit. It's less error prone once the change is done, though the change will be bigger. I think that's the right tradeoff. > BTW, there is another issue from development perspective -- it's > harder to find from where a flag is came. E.g. search for REQ_F_FOO > won't give you a place, where it was set. SQE_INHERITED_FLAGS is close > in the code to its usage exactly > for this reason. Since it's just that one spot, add a comment with the flag names or get rid of the SQE_INHERITED_FLAGS define. That'll make it easy to find. >> and with that we could have things Just Work in terms of numbering, if >> we keep the overlapped values at the start. Would need IOSQE_* to also >> use an enum, ala: >> >> enum { >> __IOSQE_FIXED_FILE, >> __IOSQE_IO_DRAIN, >> ... >> }; >> > > I tried to not modify the userspace header. Wouldn't it be better to > add _BIT postfix instead of the underscores? No strong preference, I usually do the underscores, but not a big deal to me. There's also BIT_* helpers to make the masks, we should use those. -- Jens Axboe