Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3009759lqo; Tue, 14 May 2024 17:25:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyojLXS8GdOm+zISuUeEbcx4AHyHD0iajPrycRGUJkBcwDXbczeZnJMjLH8dQnohy8h3PDZ9J+wKrkjFSClLp1jVhfK0fbZ9RwgD9JDw== X-Google-Smtp-Source: AGHT+IEAfBYAKtrNLgLrCRdXgrlTCOQMhS6+xhhEIb8mKItyB+h9mOEDe73J3YzYqd65WeQjHSvK X-Received: by 2002:a05:6870:ac9b:b0:23c:3509:35cb with SMTP id 586e51a60fabf-241728f4da3mr17265943fac.6.1715732729331; Tue, 14 May 2024 17:25:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715732729; cv=pass; d=google.com; s=arc-20160816; b=iWaxyKsp/VvvIvQqFi4+GqefpwHvcsZuGR4ZmMrmddOMczLqV0GDN4MF30HpcghY+Y /vYO0hD3oRdCRygmBe0FuDQaqhd14ykbM2dkFhF+Qcdi8+QE1f/njxqUQITiZU+AIlzU jan3x54YYov3mjEPLgi+eXWQCtVgtLvN02NmlKeIrIsWe08of+Z63lGGR8uQ+3Bpm/cx 2TZmco+BWSYB3oy0eowOUxM3WrhpE1A/VPCtbVYgAdzq1RAKuTuSkhS7jzEw0R/Uc2F1 QRGP3aMM9dZyc3t64MyAk1b9YMZmm9/KOyplHQUnSWhJEZLZ7EDZJuVmpUp2Q5Ssqxa5 5xiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=UHZT2BoZr0ijthsLDchrpbeknRtm/GuvmkXc1Pxxy/Q=; fh=YLiscq7i7YusbhIbjuQWJXnKgX0guoalbvuKGcFw/tg=; b=Sit4on35Yk1OYXl0yYCMj9NohoxZOnE5BRdl42J7imQtKY+q0zeU37KQy5QELLJV1W D5PGTA07fxcYUOejEmXJVzud/Xu21egfcJMEGjnBxZHpin/1s+5Afn4k3tMGwjDEBlMp 3X8PCtyJRxaJ5CZ5fQoX8gqoWpg788XHHuerwAp4wU3m+9Ia5T5AlF3W5D7s55DH/D9K UMxx3GiEJ6nBYq8nSIRE2ZccFO1Wo1Jb6eGC/c3za8ecI+yQj67zkxqhe+OtVngTZuZw E6lNhM0KR10bsc085TWdwlpLlNuQiJoHiIreCwJ8tVaXcBj9VCwsR3/165+TZJ69Dhiu eaGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=dKxHkkbf; dkim=neutral (no key) header.i=@suse.cz; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=dKxHkkbf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-ext4+bounces-2512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2512-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63413d7214csi12928744a12.813.2024.05.14.17.25.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 17:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=dKxHkkbf; dkim=neutral (no key) header.i=@suse.cz; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=dKxHkkbf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-ext4+bounces-2512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2512-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 93772282897 for ; Wed, 15 May 2024 00:25:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97B9FEDF; Wed, 15 May 2024 00:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="dKxHkkbf"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="RUmsnmKQ"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="dKxHkkbf"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="RUmsnmKQ" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 4C979370; Wed, 15 May 2024 00:25:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715732721; cv=none; b=dGejtmVuuANEuMmWVblD2NgvYXJg6u0GOht47lWQ0K9HefHVYi2oM7SFjvqslF9L8b9e+GNGp/LndvUXX2s/snRjSAH4W7hFD2dnkj/lW+yBiub6AX66QpK8rwb+BqtuXewCqySUC+8bc0VZsv4hSpfELPpSoTttBUCfAfRMM6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715732721; c=relaxed/simple; bh=UwwJLzqENrZle2Y4/i+YEoQ9LtfalYqLwPCpLhSIrUc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DOIMAOBeCsvwNS764W0otCZPTsLpvwt/NYR/J6ruUvDDXWct3m3kku49Jd1+P2TE3NhRrfKDJsHTJwMfoSzeBJ9XIdXnMeJIT2lJVEmPrvGw3C58F4YQUa1nVoYv/b4eOhS9/MgWKf/DS/mhwe9Oo7oxL/q+VkU0h/HlVEv0O+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=dKxHkkbf; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=RUmsnmKQ; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=dKxHkkbf; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=RUmsnmKQ; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8151C22907; Wed, 15 May 2024 00:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1715732717; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UHZT2BoZr0ijthsLDchrpbeknRtm/GuvmkXc1Pxxy/Q=; b=dKxHkkbfWr/geiKeNoSlV1mVmQf5zQreuILpWf9/GLWY/3/a5NyfxWXMVEB8uHBkbbqfa6 In94j0lIZ4i/3BbACEBrA8VoBTbC3qis5t8x2oQbTilbwCkp4ZR9ZRVKy9KYHeeOEpbh0a 9X08WDtx6L44QuzOi9TL9da9LeE9I9Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1715732717; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UHZT2BoZr0ijthsLDchrpbeknRtm/GuvmkXc1Pxxy/Q=; b=RUmsnmKQCuQfioWktYkb0msP1mHO2iwm8FFWoYA7jgNOe0RAiTN4e1xS6in7Eg4NoXJsP2 89RlT9BPhNwCPpBg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1715732717; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UHZT2BoZr0ijthsLDchrpbeknRtm/GuvmkXc1Pxxy/Q=; b=dKxHkkbfWr/geiKeNoSlV1mVmQf5zQreuILpWf9/GLWY/3/a5NyfxWXMVEB8uHBkbbqfa6 In94j0lIZ4i/3BbACEBrA8VoBTbC3qis5t8x2oQbTilbwCkp4ZR9ZRVKy9KYHeeOEpbh0a 9X08WDtx6L44QuzOi9TL9da9LeE9I9Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1715732717; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UHZT2BoZr0ijthsLDchrpbeknRtm/GuvmkXc1Pxxy/Q=; b=RUmsnmKQCuQfioWktYkb0msP1mHO2iwm8FFWoYA7jgNOe0RAiTN4e1xS6in7Eg4NoXJsP2 89RlT9BPhNwCPpBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D668F13A56; Wed, 15 May 2024 00:25:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 5i9SNOwARGbpVwAAD6G6ig (envelope-from ); Wed, 15 May 2024 00:25:16 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 41AECA08B5; Wed, 15 May 2024 02:25:13 +0200 (CEST) Date: Wed, 15 May 2024 02:25:13 +0200 From: Jan Kara To: Zhang Yi Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH] ext4/jbd2: drop jbd2_transaction_committed() Message-ID: <20240515002513.yaglghza4i4ldmr5@quack3> References: <20240513072119.2335346-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240513072119.2335346-1-yi.zhang@huaweicloud.com> X-Spam-Flag: NO X-Spam-Score: -2.29 X-Spam-Level: X-Spamd-Result: default: False [-2.29 / 50.00]; BAYES_HAM(-2.99)[99.96%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_SEVEN(0.00)[11]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[vger.kernel.org,mit.edu,dilger.ca,suse.cz,gmail.com,huawei.com]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email] On Mon 13-05-24 15:21:19, Zhang Yi wrote: > From: Zhang Yi > > jbd2_transaction_committed() is used to check whether a transaction with > the given tid has already committed, it hold j_state_lock in read mode > and check the tid of current running transaction and committing > transaction, but holding the j_state_lock is expensive. > > We have already stored the sequence number of the most recently > committed transaction in journal t->j_commit_sequence, we could do this > check by comparing it with the given tid instead. If the given tid isn't > smaller than j_commit_sequence, we can ensure that the given transaction > has been committed. That way we could drop the expensive lock and > achieve about 10% ~ 20% performance gains in concurrent DIOs on may > virtual machine with 100G ramdisk. > > fio -filename=/mnt/foo -direct=1 -iodepth=10 -rw=$rw -ioengine=libaio \ > -bs=4k -size=10G -numjobs=10 -runtime=60 -overwrite=1 -name=test \ > -group_reporting > > Before: > overwrite IOPS=88.2k, BW=344MiB/s > read IOPS=95.7k, BW=374MiB/s > rand overwrite IOPS=98.7k, BW=386MiB/s > randread IOPS=102k, BW=397MiB/s > > After: > verwrite: IOPS=105k, BW=410MiB/s > read: IOPS=112k, BW=436MiB/s > rand overwrite: IOPS=104k, BW=404MiB/s > randread: IOPS=111k, BW=432MiB/s > > CC: Dave Chinner > Suggested-by: Dave Chinner > Link: https://lore.kernel.org/linux-ext4/493ab4c5-505c-a351-eefa-7d2677cdf800@huaweicloud.com/T/#m6a14df5d085527a188c5a151191e87a3252dc4e2 > Signed-off-by: Zhang Yi I agree this is workable solution and the performance benefits are nice. But I have some comments regarding the implementation: > @@ -3199,8 +3199,8 @@ static bool ext4_inode_datasync_dirty(struct inode *inode) > journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; > > if (journal) { > - if (jbd2_transaction_committed(journal, > - EXT4_I(inode)->i_datasync_tid)) > + if (tid_geq(journal->j_commit_sequence, > + EXT4_I(inode)->i_datasync_tid)) Please leave the helper jbd2_transaction_committed(), just make the implementation more efficient. Also accessing j_commit_sequence without any lock is theoretically problematic wrt compiler optimization. You should have READ_ONCE() there and the places modifying j_commit_sequence need to use WRITE_ONCE(). Honza -- Jan Kara SUSE Labs, CR