Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1388764pxj; Fri, 21 May 2021 13:02:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqGZ4q0GY81DHpoFdGwcTd5Na4JksfpkwF3QvuIt03EsVM0oL4XyZBwMYFRTht1XO4kFL4 X-Received: by 2002:a50:9549:: with SMTP id v9mr8506846eda.312.1621627322851; Fri, 21 May 2021 13:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621627322; cv=none; d=google.com; s=arc-20160816; b=JrHxuShUOt2HHwfTtkTbNCyZhHrynSCVG0hSHywyEA5T0z5RnyOSQB2W6bRfN3owza Y/mjE8MIn6koV0f4sMLb4yJcZvLYN6m1c8kgFE24UupMxhLt/li+oPoDTVAk1xlYjfDP 5pA+E2imUlcG/B1mKJdN+CULl01J9kntm3N5bH+C7Bz1oW5EPTq8JvNM/ihAl9WeiPAv 7VR0iHoBMtNl8oCa1zdPHSqtx4qlWz2rdD9o4WJaNTGSjAi8uns1m//3zFMnQuw07CbX WkNqAfXYU75K9P2AfZyj0m/Lfv1r6UN3i+9veMt8U2kR6sFhAV+WD3QqsIIbvNr3UUMR 3pVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=jZ8b9uIzmHw1BsqRLjKNK/1NTGzSa2HXvmJMPRWZ25A=; b=f+NSUZYXcsDrXNJiD3Z0IGykeSm/0TZ2zSU77ISLBFVHdKi0SnAgzdG8YIix9owvgf kGjKiiOseEi9MYLr9vj3CwmMzY3TjG2vhqA+V1x2R4V6VPwde/puTvkKd1KYH3HMRhEH Cn2M/uJU/X0B4rhQNVLYY6StmMwyknCQvMivBM24+zLYF3RnbVxqXAO7jnlhjsCjI7Yi 5DLo8qCjngkii8ukSOrUcFuqpZSpJy+Er3Mo8jwUw2VmbxM7Tv5K5yvRVPzlg2VjiW3H RmVkdDKsNZdQrJA15pfVzISHmVFg1EUFfl2FZevLwzJtHsD4W8X+DzzdfQvWGGY3y+Vp lA9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uC5DotBV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si2640539edo.215.2021.05.21.13.01.39; Fri, 21 May 2021 13:02:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uC5DotBV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231823AbhETWrh (ORCPT + 99 others); Thu, 20 May 2021 18:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbhETWrg (ORCPT ); Thu, 20 May 2021 18:47:36 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3293EC061574; Thu, 20 May 2021 15:46:12 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id n17-20020a7bc5d10000b0290169edfadac9so6329783wmk.1; Thu, 20 May 2021 15:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jZ8b9uIzmHw1BsqRLjKNK/1NTGzSa2HXvmJMPRWZ25A=; b=uC5DotBV8MAOeL0un17S4ig29m7QXgYG5Z+bkw7kGbjlA3QMOm1cZ/6YYkZyjP7AYN qI8MDReQCNVIh9Wmft87Z9T3rXHCfmTp3iQ1qafoJ24ztBaDtMnXeNp7MwlvVGUKS2pZ e0t1xW753pJXBHRRnIK3ySltrYh0VyaCUZ1B/iG8Qo9Q+Mlf8OR9g4HR6q/IVNygKrZl yUY6ekMVLwk3bYN4SkOndcm4puSJ843GaGyTeDEavU/wRtqJ6yzeiT/GK0Cdo47E6mZy 5U1LcaLr1bfAx7q+hNEh9SwpS9H5/y3K+LLYRxeKMv+LUe2myoc6TicaxhRIlPUH6uX9 la+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jZ8b9uIzmHw1BsqRLjKNK/1NTGzSa2HXvmJMPRWZ25A=; b=sf/5WQZ6p0C2K+u0Dnfot0I2anWKyld11LO2/zG2QI9ffY/ei6xfpqaYQqAbQ9pugO 0LKKZ1dD+qpDh2Oz1oPHVoy8pt8UONtYJWIhx4vngtNuiDQBP+VjFL4dJ4wDvFDqbrwH MRjHMTBMPPhpcUTjpFQEIkJOb1NUtNcaFjej0Cos2HuF3xOCqugSV4NyZfD3hCIMvUmJ HYsOtArkTeLERBtOu0mMOn9mfMfwYJrFS/376anTQ2HWUm4j1FO6u2+pUEV84PVAKgDr 9dmILiLmGmldnzvJ7h06dYigwn6pnwjZLezO6Y2EPz6TbzW/sETppb5y2OoYdRHbVHmo 6l3w== X-Gm-Message-State: AOAM531bYcPDn8BqyrnzVWFCdxzBbnN9LD+0EL1zW7deCmz0E96vsxjn P2p+c7abhNze46w0AbTueV4= X-Received: by 2002:a7b:cb45:: with SMTP id v5mr5866848wmj.48.1621550770788; Thu, 20 May 2021 15:46:10 -0700 (PDT) Received: from [192.168.8.197] ([85.255.236.182]) by smtp.gmail.com with ESMTPSA id t5sm4784634wmi.32.2021.05.20.15.46.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 May 2021 15:46:10 -0700 (PDT) To: Song Liu Cc: "io-uring@vger.kernel.org" , Networking , "bpf@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jens Axboe , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin Lau , Yonghong Song , John Fastabend , KP Singh , Horst Schirmeier , "Franz-B . Tuneke" , Christian Dietrich References: <485abb65cf032f4ddf13dcc0bd60e5475638efc2.1621424513.git.asml.silence@gmail.com> <0339DB35-27AC-4A50-B807-968C72ABB698@fb.com> From: Pavel Begunkov Subject: Re: [PATCH 01/23] io_uring: shuffle rarely used ctx fields Message-ID: <45a6f8f9-7abf-f513-e872-c346a682e373@gmail.com> Date: Thu, 20 May 2021 23:46:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <0339DB35-27AC-4A50-B807-968C72ABB698@fb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/20/21 10:46 PM, Song Liu wrote: >> On May 19, 2021, at 7:13 AM, Pavel Begunkov wrote: >> There is a bunch of scattered around ctx fields that are almost never >> used, e.g. only on ring exit, plunge them to the end, better locality, >> better aesthetically. >> >> Signed-off-by: Pavel Begunkov >> --- >> fs/io_uring.c | 36 +++++++++++++++++------------------- >> 1 file changed, 17 insertions(+), 19 deletions(-) >> >> diff --git a/fs/io_uring.c b/fs/io_uring.c >> index 9ac5e278a91e..7e3410ce100a 100644 >> --- a/fs/io_uring.c >> +++ b/fs/io_uring.c >> @@ -367,9 +367,6 @@ struct io_ring_ctx { >> unsigned cached_cq_overflow; >> unsigned long sq_check_overflow; >> >> - /* hashed buffered write serialization */ >> - struct io_wq_hash *hash_map; >> - >> struct list_head defer_list; >> struct list_head timeout_list; >> struct list_head cq_overflow_list; >> @@ -386,9 +383,6 @@ struct io_ring_ctx { >> >> struct io_rings *rings; >> >> - /* Only used for accounting purposes */ >> - struct mm_struct *mm_account; >> - >> const struct cred *sq_creds; /* cred used for __io_sq_thread() */ >> struct io_sq_data *sq_data; /* if using sq thread polling */ >> >> @@ -409,14 +403,6 @@ struct io_ring_ctx { >> unsigned nr_user_bufs; >> struct io_mapped_ubuf **user_bufs; >> >> - struct user_struct *user; >> - >> - struct completion ref_comp; >> - >> -#if defined(CONFIG_UNIX) >> - struct socket *ring_sock; >> -#endif >> - >> struct xarray io_buffers; >> >> struct xarray personalities; >> @@ -460,12 +446,24 @@ struct io_ring_ctx { >> >> struct io_restriction restrictions; >> >> - /* exit task_work */ >> - struct callback_head *exit_task_work; >> - >> /* Keep this last, we don't need it for the fast path */ >> - struct work_struct exit_work; >> - struct list_head tctx_list; >> + struct { > > Why do we need an anonymous struct here? For cache line alignment? > Do we need ____cacheline_aligned_in_smp? Rather as a visual hint considering that most of the field historically are in structs (____cacheline_aligned_in_smp). Also preparing to potentially splitting it out of the ctx struct as it grows big. First 2-3 patches are not strictly related to bpf and will go separately earlier, just the set was based on. >> + #if defined(CONFIG_UNIX) >> + struct socket *ring_sock; >> + #endif >> + /* hashed buffered write serialization */ >> + struct io_wq_hash *hash_map; >> + >> + /* Only used for accounting purposes */ >> + struct user_struct *user; >> + struct mm_struct *mm_account; >> + >> + /* ctx exit and cancelation */ >> + struct callback_head *exit_task_work; >> + struct work_struct exit_work; >> + struct list_head tctx_list; >> + struct completion ref_comp; >> + }; >> }; >> >> struct io_uring_task { -- Pavel Begunkov