Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp578491pxb; Thu, 13 Jan 2022 12:20:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/lgePWhDPb/ysuGXRa5eQS0+n1u1UigO5pJQSCjHwyhtiNnIhMiq1touAvhVL6JjIwNku X-Received: by 2002:a17:90b:4b0e:: with SMTP id lx14mr6957565pjb.66.1642105233064; Thu, 13 Jan 2022 12:20:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642105233; cv=none; d=google.com; s=arc-20160816; b=QGAFKCQrX0L/Au4h+MM3MHc9iOwzBSgC9wYhhlq3Lfxlf/08XjoJwpqO9Idkw//fHJ qUQS0puZiLxBU/QFQhjwtoTaqVMcusDBczEFae0tl0pAeq3dELgpYvQkz0bQ6wmH4tVy lGVkGE3BoEr4Lst5J2BeZuTA+Es+5TFBEvrBbU6FgyB+hf+22R8IpOcaPKzg3d5G8lnj fEmC9b3qIcd4ymsHHLRp7SFBaont8WzG3xwEpWlK8ZZBvTp4C+EuDobBKjyagfKkEEiI 3I43T67NSNhQanU84FKzWvGDhQwqHi1n4addYVkosuK3fIA5tymKGbyeIPgo3q+ttnaF 2u/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=D7+ZKGdHs7N8lXUJv5riuyYwvPvtWC0CcxPd3Kx/t2M=; b=gKRih+iLxVwXY8fA9djKjAROwnw9lSk1/bF+hPYjqbjs4r+QW1aLAEFA1eqpkcpOP1 e77l2y9w4HS1yd+RcR0fOeNDmAqhIn1Noz19fLe8sm/Dro31PJULMQPIhYPz28vcbQjS kMjjlbnk8a8yBcoK7EpbgMYOztE1QDMJ0aw3ALgm+keF35aqH/RvOuGW2ci0wLH0jAJZ XEjBj4Nfalgv7YMMwliuD7jmRqiWFMcRmBRIJ0q5NSg2oscpnebJZmKd42fKkuVX6WV4 qwX4nZa+3f28fS3Gfl/HbgsXIzRcQ8ejBccDoGOQDw9GKKQHILyqgVqg+W57s3ZP93uJ i6kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=CjkjQEHz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f37si3682900pgb.762.2022.01.13.12.20.07; Thu, 13 Jan 2022 12:20:33 -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; dkim=pass header.i=@ibm.com header.s=pp1 header.b=CjkjQEHz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233593AbiAMMi5 (ORCPT + 99 others); Thu, 13 Jan 2022 07:38:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51442 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232900AbiAMMi5 (ORCPT ); Thu, 13 Jan 2022 07:38:57 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20DCT15d015119; Thu, 13 Jan 2022 12:38:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=D7+ZKGdHs7N8lXUJv5riuyYwvPvtWC0CcxPd3Kx/t2M=; b=CjkjQEHzRIKn+FO/5EdM4KNrEIU72bxQZIW4c83MlLCdqn/5gs2hgVe5oAiK1+EYMrNs nmRG8p67kPFapLB65MOJd+KVFn+t2aCQya/T8I3tI7z2PhcfgOwzkN2q6ylFmPtOOi2L XO5fnQHXuwUUHArrP46CCfyGo9oR3iZq/Fz/J2DqJyqMVV9zS940ma4u3LHqd9aFupRE aliC8Cxs6YALIZNLy9RG4XdWmn4bieY9MjVKB/GQZ2oxH22iZUX1gwg/tQOKu61HN3rF bFpEySVE+UFDDf4lRfV4arEaQgY+MOyOmX8RVuhBF8Uv8JU9LCk6kTSqkkIMdW2BBif1 Xg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3djjbxj89w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 12:38:49 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20DCUXAf024113; Thu, 13 Jan 2022 12:38:48 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3djjbxj89d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 12:38:48 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 20DCcIwD031705; Thu, 13 Jan 2022 12:38:46 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06ams.nl.ibm.com with ESMTP id 3df1vjmhdd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 12:38:46 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20DCciuB45613526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jan 2022 12:38:44 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B869A406E; Thu, 13 Jan 2022 12:38:44 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 940F8A4065; Thu, 13 Jan 2022 12:38:43 +0000 (GMT) Received: from localhost (unknown [9.43.54.234]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 13 Jan 2022 12:38:43 +0000 (GMT) Date: Thu, 13 Jan 2022 18:08:42 +0530 From: Ritesh Harjani To: Jan Kara Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Andreas Dilger , tytso@mit.edu, Eric Whitney Subject: Re: [PATCH 6/6] jbd2: No need to use t_handle_lock in jbd2_journal_wait_updates Message-ID: <20220113123842.3rpfcyecylt5n3wo@riteshh-domain> References: <20220113112749.d5tfszcksvxvshnn@quack3.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220113112749.d5tfszcksvxvshnn@quack3.lan> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6Cn2v6OG7A4s6QRjewK07qtJCT-HNgvi X-Proofpoint-GUID: S08JEU3Z0S9v0cMSbxsI7xEy65BB9m0d X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-13_04,2022-01-13_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 spamscore=0 malwarescore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201130075 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 22/01/13 12:27PM, Jan Kara wrote: > On Thu 13-01-22 08:56:29, Ritesh Harjani wrote: > > Since jbd2_journal_wait_updates() uses waitq based on t_updates atomic_t > > variable. So from code review it looks like we don't need to use > > t_handle_lock spinlock for checking t_updates value. > > Hence this patch gets rid of the spinlock protection in > > jbd2_journal_wait_updates() > > > > Signed-off-by: Ritesh Harjani > > This patch looks good. Feel free to add: > > Reviewed-by: Jan Kara > > Actually looking at it, t_handle_lock seems to be very much unused. I agree I too had this thought in mind. Thanks for taking a deeper look into it :) > > we don't need it when waiting for outstanding handles but the only > remaining uses are: > > 1) jbd2_journal_extend() where it is not needed either - we use > atomic_add_return() to manipulate t_outstanding_credits and hold > j_state_lock for reading which provides us enough exclusion. > > 2) update_t_max_wait() - this is the only valid use of t_handle_lock but we > can just switch it to cmpxchg loop with a bit of care. Something like: > > unsigned long old; > > ts = jbd2_time_diff(ts, transaction->t_start); > old = transaction->t_max_wait; > while (old < ts) > old = cmpxchg(&transaction->t_max_wait, old, ts); > > So perhaps you can add two more patches to remove other t_handle_lock uses > and drop it completely. Thanks for providing the details Jan :) Agree with jbd2_journal_extend(). I did looked a bit around t_max_wait and I agree that something like above could work. I will spend some more time around that code and will submit those changes together in v2. -ritesh > > Honza > > > --- > > include/linux/jbd2.h | 4 ---- > > 1 file changed, 4 deletions(-) > > > > diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h > > index 34b051aa9009..9bef47622b9d 100644 > > --- a/include/linux/jbd2.h > > +++ b/include/linux/jbd2.h > > @@ -1768,22 +1768,18 @@ static inline void jbd2_journal_wait_updates(journal_t *journal) > > if (!commit_transaction) > > return; > > > > - spin_lock(&commit_transaction->t_handle_lock); > > while (atomic_read(&commit_transaction->t_updates)) { > > DEFINE_WAIT(wait); > > > > prepare_to_wait(&journal->j_wait_updates, &wait, > > TASK_UNINTERRUPTIBLE); > > if (atomic_read(&commit_transaction->t_updates)) { > > - spin_unlock(&commit_transaction->t_handle_lock); > > write_unlock(&journal->j_state_lock); > > schedule(); > > write_lock(&journal->j_state_lock); > > - spin_lock(&commit_transaction->t_handle_lock); > > } > > finish_wait(&journal->j_wait_updates, &wait); > > } > > - spin_unlock(&commit_transaction->t_handle_lock); > > } > > > > /* > > -- > > 2.31.1 > > > -- > Jan Kara > SUSE Labs, CR