Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp531228pxb; Wed, 13 Jan 2021 09:21:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKMBwBLg2L1DCQ5VI9i4ClM/EJ06Gw8gtR+wJOGbaeDPpIDr6Df1TgbArRo6IgYF34qyGL X-Received: by 2002:a17:906:b082:: with SMTP id x2mr2201802ejy.100.1610558519736; Wed, 13 Jan 2021 09:21:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558519; cv=none; d=google.com; s=arc-20160816; b=B0pLsZ2s8vPpu4q5y/zZSOW34unwYbAhRfaN67fPuxQp6/B+easNBMqB1PXhfBBMGt 7yolPf5QwTP8warKfI1KobFkLo+3IvkDDxGGv5/ezgOXIhCpW2JuEoK52iLMKwtosQfN Cwjw74pZWf90jGXfA5wqSjgaqb40rELed33+rafPmqhfF1jl5PAMaaIfDt+aRSDtvC5O onnO2o7XgeAN6CQsym4ld2/X9snNvjPPfs5d8YIynZKCOLWc2EHQ864u4mPmWlASVa3o B3qBmalhfI8sIcw28xnwrMQKYvYUz3z5hlymj8hygFXf29TKZ9rMaSDelyROCOe3UNKI EIwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=TOwMIQYzw0Pbe4zkVMTtqN40Z7I/soNvxgbOZErQwJE=; b=HauQPWqefCjro3KGKfZnUlvavBbIoNoRrM2wepuIJTukGN4o3sy0rb2PG42XDX1yuc SXpcBsD7cV2B7+Qo3jg9AH/YGWwprPEHlew3cQYCS6/EWwvqBVhm5agXbu8O5EUYK2/Q +reQGgOl4TFS13DyYfDF97jWweV++s1Q7u/ceYpnAUs0lKM/PFVK/DuhEyS8W+4PjNE5 phfbEE8c1JLQUZrlDRwJKulMtxk0X6MRylDSBNPw02bW4yzak+MiSAuLSAI0WvvdLKSY nUIOxYf7oHiNxyEDXvuIwt4dWsfvDc+z2ddJ1SnohMUlEq4aAi/KpyD5+gkT/134/1zi ynag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i1si1145577eds.174.2021.01.13.09.21.33; Wed, 13 Jan 2021 09:21:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728136AbhAMRU0 (ORCPT + 99 others); Wed, 13 Jan 2021 12:20:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:34688 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbhAMRU0 (ORCPT ); Wed, 13 Jan 2021 12:20:26 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5B0DEACAC; Wed, 13 Jan 2021 17:19:44 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id DA9031E083D; Wed, 13 Jan 2021 18:19:43 +0100 (CET) Date: Wed, 13 Jan 2021 18:19:43 +0100 From: Jan Kara To: Xiaoguang Wang Cc: Ext4 Developers List , joseph qi Subject: Re: code questions about ext4_inode_datasync_dirty() Message-ID: <20210113171943.GB26686@quack2.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi! On Tue 12-01-21 19:45:06, Xiaoguang Wang wrote: > I use io_uring to evaluate ext4 randread performance(direct io), observed > obvious overhead in jbd2_transaction_committed(): > Samples: 124K of event 'cycles:ppp', Event count (approx.): 80630088951 > Overhead Command Shared Object Symbol > 7.02% io_uring-sq-per [kernel.kallsyms] [k] jbd2_transaction_committed Hum, that's quite a bit. Likely due to cacheline contention on j_state_lock. Thanks for reporting this! > The codes: > /* > * Writes that span EOF might trigger an I/O size update on completion, > * so consider them to be dirty for the purpose of O_DSYNC, even if > * there is no other metadata changes being made or are pending. > */ > iomap->flags = 0; > if (ext4_inode_datasync_dirty(inode) || > offset + length > i_size_read(inode)) > iomap->flags |= IOMAP_F_DIRTY; > > ext4_inode_datasync_dirty() calls jbd2_transaction_committed(). Sorry, I > don't spend much time to learn iomap codes yet, just ask a quick question > here. Do we need to call ext4_inode_datasync_dirty() for a read > operation? So strictly speaking we don't need to know the value of IOMAP_F_DIRTY in that path (or any read path for that matter) but I'm somewhat reluctant to optimize out setting of this flag because later some user might start to depend on it being set correctly. > If we must call ext4_inode_datasync_dirty() for a read operation, can we improve > jbd2_transaction_committed() a bit, for example, have a quick check between > inode->i_datasync_tid and j_commit_sequence, if inode->i_datasync_tid is less than > or equal to j_commit_sequence, we also don't call jbd2_transaction_committed()? Well, the modification would belong directly to jbd2_transaction_committed(). Using j_commit_sequence is somewhat awkward since TIDs can wrap around and so very old TIDs can suddently start to give false positives leading to a strange results (this was one of motivations to switch jbd2_transaction_committed() to a comparison for equality). But it could certainly be done. But j_state_lock is a scalability bottleneck in other cases as well. So what I rather have in mind is that we could change transactions to be RCU freed and then a majority of places where we use read_lock(&journal->j_state_lock); can be switched to using plain RCU which should significantly reduce the contention on the lock. Honza -- Jan Kara SUSE Labs, CR