Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1016111lqj; Mon, 3 Jun 2024 07:52:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzrDTMC96UzazLrxSuY917xp8egBOIz5V5v49dzSV9a5hNYmp8ST0moUkp4CGfVs5MVMk7sJv8OjnVq1yQ3/5VGfPm9KIaXyvkpqS38Q== X-Google-Smtp-Source: AGHT+IEjGd2C3QyYvPjfY/Pzi9IJHQdcOVU8ZMQoYFIt7lHAbx2b+B1F8QVQh39HPFObKP5GiPOk X-Received: by 2002:a05:6a21:2729:b0:1a3:c3a9:53b7 with SMTP id adf61e73a8af0-1b26f27d9ddmr7586817637.55.1717426370181; Mon, 03 Jun 2024 07:52:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717426370; cv=pass; d=google.com; s=arc-20160816; b=UKMucWSqrh8Wr7O4dDIOmSWsv4g+INElRzkrePIqJQjn88F7Dn4uj6g2uyRo+BRhNK wJrq1+e4J0lkXmy6plBg5doCnMoZe7ovSmalWZxg8JZnKicVWG3Z7hjCt80NiePI5uIY h8rzSwO7Y4v9FTzU83rVx7nrPL5ivACixDyowfG9eWCs2yb4Ax/7nZ9SmJbeQTHb8avh YHnqtsMqZCCOwost77fDl3+SMz0miTRsP3lO2oBiVA0tYUYXFR5nv4ConDS3UO70R7LA JeI6yrAbUGUfzz9z7U9J2sEonbYJPf8q25ULr1dUp6Aa9aHP/vp5pgzCIpPt8JTgLBl9 jdcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=t0ILl6untH+VccYEAmzkW+dUDoohQnatMzvdT/ns45o=; fh=TsoxzNA/3d74/QozAaZ4iIhmD7ovxAsAaawJXVJDzPQ=; b=ruJV7Zaqr2JdW++xXuWfaMbkOvT1udX6QZtbeI/6VHeaiOF4UnVCdFP3pqigfOzTAV eYGBKoxmIek7LtEGGTlKn/HcnMWBDfpwD71A7CliGuEUovxyuqO3BcxTWwqYv8iC3nPw rTSakPg//fguuJN1l1UAktMuH2PZUIlJQDLipRd48ENTfR6KAr3e+V8I730B+JUqfgNP vtkpjLvQpJ7d77r5VUew6WRtLPjaM7Cpb3Kcc0zuC9UBy93KxgVP1XJpXdymh+Y6LUV+ ZnGnC1htqK0QZF8dzdKiHmI5OGWcG/pS2jTnpeNlcx5PSVLeR+dwGggt1/jQPO6Zc1Qy tigw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lw9GPi8t; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-2755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-7027ec9fa52si192458b3a.294.2024.06.03.07.52.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 07:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lw9GPi8t; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-2755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 39B9BB2491B for ; Mon, 3 Jun 2024 14:43:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 343DD130A76; Mon, 3 Jun 2024 14:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lw9GPi8t" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3288F130A54 for ; Mon, 3 Jun 2024 14:43:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717425810; cv=none; b=I1W7zDLSpCsN7Lh++OUijx19q2nqkpEH/spJPqggIzb72HbMQslZewfMaZMJMNn+e66d++/zrUyQlLqZwSyfBUUpjyyXlNjfffsx1YJXVumdDZPLh/fLAP+8a8FR2x9tRynLwDFrGZGQxOQNUfX0lOFezevNRRnSRDOUYHT6LzU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717425810; c=relaxed/simple; bh=qoJ5Iy4yFwa1SFVcehQ4ALiqel5bYIC+hTfSwU2yAjA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SaBjs5FRykxn7bMgraRFugxhsxCG0JV7YXxHzmYKCMrIdCeOwRvGl092q3SqY3mjHIn9v9jYypANOsuDCLcdzheCg2MI746ztOtu3SfVp/qQ/GS84TcYX9rjR87P0dalML4rnTcseeLwhYfHeNNiqIJFWMqXTD2vRlLkhqbyCwQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lw9GPi8t; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57a1fe63a96so3901309a12.0 for ; Mon, 03 Jun 2024 07:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717425808; x=1718030608; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=t0ILl6untH+VccYEAmzkW+dUDoohQnatMzvdT/ns45o=; b=lw9GPi8tckh0CgidC80CWyfKS6RztSPtHPPopKV36CgRCoda/ZrsJaHx6DkC9YYOEN m2Me2tt04i7QcQDBkDnadNir2sbv0NkpQYWg0UmOTo0GZhlIYi3Sg3mO15pBePH1Tvu1 TUnfQ1q5M+MC2ZGj1RbE0FHh4y6AIpquTsrJXK1lkm4LGsedQIIDkNMQQPwHVCHlllTz OwmD6oqsnLwZNg8AMLNpSJyK1g+dUHDFMnkdjfTHbkkTq55KptpK4hiidc74tlDBPBKh EXOh1bK4eg8f4W5gQmMEaaj9icSCl0jxWW+qEnEql6S6spC3BlMOHX3t6q3HlPJc6ZEs Zjcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717425808; x=1718030608; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t0ILl6untH+VccYEAmzkW+dUDoohQnatMzvdT/ns45o=; b=K8GHCpIJuXWVvOjyOb0G5Q11Byb6XeU58HrqS5Jrr5ky1jhCRHgNsr+5mDgfY0sEqm mfD/iofDq23IZJL7zHsTHY+DMnCu6R3HMc1XzNTrqI5CDpSeQMRAE7jFM2HLHcJ1rldc MEZNpKiTYSEqAvqvCpucHiiMr/dvP/r/MJcjdAMGIDOc6wHj6W/9lH3v7cXZ4SOpfQDj dkQ6gOYhls34R+VlEnTlMfTZVQPUQiRl+xmMCp3/Y6eDXXYeg5pLopLIaB2JU0QhwwQC vjXvJI05r62kil4rws7k1ase+CzTtiqHhpKopmO/XorIFk8bDtpGP0F5CTYIzdP4pp/7 0exw== X-Gm-Message-State: AOJu0Yz1UNU3D2dKVUQvBcyT4zJbNwPPPuuIlDzS7kuYSJSNw8IzmG19 c8WEayCoCOV6o1AtIvGR+N7wRyEmZhM6CI/mz3/DgRnWKSKuZD9pr0zo4d9IRDxuJBeUbBTHxrJ Sla2B1/fUYWF7Dr1qDhUR0hRrJ5k= X-Received: by 2002:a50:ba89:0:b0:57a:321f:cc4f with SMTP id 4fb4d7f45d1cf-57a3f55eb7emr6178429a12.19.1717425807401; Mon, 03 Jun 2024 07:43:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240603131524.324224-1-sunjunchao2870@gmail.com> <20240603140705.vfpdrbyljw6yfxpd@quack3> In-Reply-To: <20240603140705.vfpdrbyljw6yfxpd@quack3> From: JunChao Sun Date: Mon, 3 Jun 2024 22:43:16 +0800 Message-ID: Subject: Re: [PATCH] ext4: Adjust the layout of the ext4_inode_info structure to save memory. To: Jan Kara Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Jan Kara =E4=BA=8E2024=E5=B9=B46=E6=9C=883=E6=97=A5=E5=91=A8= =E4=B8=80 22:07=E5=86=99=E9=81=93=EF=BC=9A > > On Mon 03-06-24 21:15:24, Junchao Sun wrote: > > Using pahole, we can see that there are some padding holes > > in the current ext4_inode_info structure. Adjusting the > > layout of ext4_inode_info can reduce these holes, > > resulting in the size of the structure decreasing > > from 2424 bytes to 2408 bytes. > > > > But AFAICT this will save two holes 4 bytes each so only 8 bytes in tot= al? > > Not 16? Indeed it's 16. Consider the layout int a; hole 0; int b; hole 1; And then move int b to hole 0 position, this adjustment resulted in saving 8 bytes. There are two adjustments like this, so it's 16. And GDB confirmed this. > > > > > Signed-off-by: Junchao Sun > > Otherwise looks good. Feel free to add: > > Reviewed-by: Jan Kara > > Honza > > > --- > > fs/ext4/ext4.h | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > > index 023571f8dd1b..42bcd4f749a8 100644 > > --- a/fs/ext4/ext4.h > > +++ b/fs/ext4/ext4.h > > @@ -1055,6 +1055,7 @@ struct ext4_inode_info { > > > > /* Number of ongoing updates on this inode */ > > atomic_t i_fc_updates; > > + atomic_t i_unwritten; /* Nr. of inflight conversions pending */ > > > > /* Fast commit wait queue for this inode */ > > wait_queue_head_t i_fc_wait; > > @@ -1103,6 +1104,10 @@ struct ext4_inode_info { > > > > /* mballoc */ > > atomic_t i_prealloc_active; > > + > > + /* allocation reservation info for delalloc */ > > + /* In case of bigalloc, this refer to clusters rather than blocks= */ > > + unsigned int i_reserved_data_blocks; > > struct rb_root i_prealloc_node; > > rwlock_t i_prealloc_lock; > > > > @@ -1119,10 +1124,6 @@ struct ext4_inode_info { > > /* ialloc */ > > ext4_group_t i_last_alloc_group; > > > > - /* allocation reservation info for delalloc */ > > - /* In case of bigalloc, this refer to clusters rather than blocks= */ > > - unsigned int i_reserved_data_blocks; > > - > > /* pending cluster reservations for bigalloc file systems */ > > struct ext4_pending_tree i_pending_tree; > > > > @@ -1146,7 +1147,6 @@ struct ext4_inode_info { > > */ > > struct list_head i_rsv_conversion_list; > > struct work_struct i_rsv_conversion_work; > > - atomic_t i_unwritten; /* Nr. of inflight conversions pending */ > > > > spinlock_t i_block_reservation_lock; > > > > -- > > 2.39.2 > > > -- > Jan Kara > SUSE Labs, CR