From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6018E18FC9D; Thu, 10 Apr 2025 06:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.194.254.142 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744266416; cv=none; b=TN87hPqYvwM2Deux7PzVEmAtZF0UtKY+JUd4sS6nfhewryeHbhV7Zpc0XIKBdwsmAVHI8OLGkWR9FxiIEC/hH3JhDy7oU7JBB+Syb2YzGeJDxAPO/a66pZn8glrJnIV1U1FEo5sohv9zOqyBwkl/C0p9DPrVQ3q2Gq3r8IG0v0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744266416; c=relaxed/simple; bh=NPC8M1VVWPm6aEQ8qWpzIuboTMn6DGJ0CqHC/ocdn2A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kGQEjlbIMYifqhUNAs2MTCOYoAvUmH2eCO56Fiv0bYpwdtYDXqWxPPUDPMgDcFqCAjLh3rw5OVWNgsJ9y+qBA711uLh7CSwdbFx/7hf47ETwtgJvE36Xzwn1+hhLj2Xn98hb/SV0tI/cYtEpUDGusoEyXxzEYWjLKhtsxQ5IOz8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=COIHO/o9; arc=none smtp.client-ip=18.194.254.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="COIHO/o9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1744266342; bh=9APvfSMmJoCREHVgkcYr5TtNKHpDJ5ObAjJQ5AxzhhM=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=COIHO/o98/dbKUt1kSBfnw53ZysPlqNsUWobTL1GBNv3tftL9u81layW+jjbZn0oN RoRnFRpfYg5kgm00cV0QZBt6IaJRMY1p+zoH16xvrBr1VvPpuNkKxfvHaQaXe/65KK WerMc8mWMih8KMUH0QdufOmhr9W55rToR86F8G9k= X-QQ-mid: bizesmtpsz5t1744266324t2f5fc6 X-QQ-Originating-IP: ul5BMEN48JfCl4FzAsJcEVJB+Z0rDjiLet/u8z/h/B4= Received: from [10.7.13.51] ( [125.76.217.162]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 10 Apr 2025 14:25:20 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 10198454882848788505 EX-QQ-RecipientCnt: 8 Message-ID: Date: Thu, 10 Apr 2025 14:25:19 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V2] iomap: skip unnecessary ifs_block_is_uptodate check To: Christoph Hellwig Cc: brauner@kernel.org, djwong@kernel.org, gouhaojake@163.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, wangyuli@uniontech.com References: <20250408172924.9349-1-gouhao@uniontech.com> <20250410054223.3325-1-gouhao@uniontech.com> From: Gou Hao Reply-To: Z_dc-UmJs0F1UWTN@infradead.org In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-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oOYHLrvpBl1Y6j1BCq9OCPAxxZyH1Nz3IBrM0THcWI1KfVy tMyTMMs3M5PapBI7Veaj6DiKlpfMVR4bCoONEiTFVUY896LrPgJB5FZG5t7Ko= X-QQ-XMRINFO: Nq+8W0+stu50PRdwbJxPCL0= X-QQ-RECHKSPAM: 0 On 2025/4/10 13:54, Christoph Hellwig wrote: > On Thu, Apr 10, 2025 at 01:42:23PM +0800, Gou Hao wrote: >> prior to the loop, $i is either the first !uptodate block, or >> it's past $last. Assuming there's no overflow (there's no combination >> of huge folios and tiny blksize) then yeah, there's no point in >> retesting that the same block $i is uptodate since we hold the folio >> lock so nobody else could have set uptodate. > Capitalize the first word in the sentence and use up the 73 characters > available for the commit log: > > In iomap_adjust_read_range, i is either the first !uptodate block, or it > is past last for the second loop looking for trailing uptodate blocks. > Assuming there's no overflow (there's no combination of huge folios and > tiny blksize) then yeah, there is no point in retesting that the same > block pointed to by i is uptodate since we hold the folio lock so nobody > else could have set it uptodate. Thank you, i will change the log in next patch. >> /* truncate len if we find any trailing uptodate block(s) */ >> - for ( ; i <= last; i++) { >> + for (i++; i <= last; i++) { > A bit nitpicky, but I find a i++ in the initialization condition of a > for loop a bit odd. > > What about turning this into a: > > while (++i <= last) { > > ? Yes,  it is better.  I will test this. >