Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2204563pxj; Sun, 9 May 2021 19:10:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnkjloGGSrIMoWVvDP+X4rVCCcqT1qE1/8u9+KYHgQGQSz7FrfQvn56Jwl3FmlqOCIQcCh X-Received: by 2002:a5d:8441:: with SMTP id w1mr16518736ior.210.1620612619942; Sun, 09 May 2021 19:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620612619; cv=none; d=google.com; s=arc-20160816; b=lKpXKYZdcsgcTPpx2bv6L3+hbxbEUCHHUmm5BRO0+N4/qbTCecLQHFMMUsFJHNQ4Nv 36Bn9QODnPl7FIDGoeSMLfxO8MY5rWvSJSPnFxMZjjzpw95mZ0vDQk3pspXGX5+gcsqR 5oa8gzFB9NEAFLsVNEwusETy7MoQuQ9VYdMc0NsAFtozY9ROnEyNsE8JrkMAaapjIZ4b DBhbDGJ6250GWaz9plqzKx9YNqTP//RTawaRtQSKyOw74bMH41Ddr4lW0XuXLK8RypwC 7fRWRragkt+A4weCHOYC18NY/vkwXWVkiJ0V8JrYgT0nXPGU1/iIUrtNG9mTr89GHvWm TaXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:date:message-id:references:cc:to:from :dkim-signature:subject; bh=K6LfNONk6HfppzX/jONH/LDGPxC6N7vLNarqHb5nLjI=; b=Uock1pzvUUG23BuWhzJq+zcPAFnQtEhxKUjcM3QbZZLUtnjzjP1F9TjVICD9Vw+2R9 sSeyUYvhhaMlhkfwaIw78w9w/W8dLnfXGY3vrqpxQ6xAePesPKx5Br7xOULpVqs0f2Ju F9GOi5TIBBS4AcSJvQ/EFT4o5PEw/Dx9i47qT21Vz1UyClxaztB8MCwjey9VHw9S14Uu nfAIo/vfsya0KLf843kgIRszXtybQvk0n44B7SteFVLVY/wtAU4M+Ei5WfnkCdqML41y 5yAyMAc0L/m64c3sVQPKaOX5gtp/h0VIjvuraxhz/VV1DThFvVWAXXhgxpDWRnkEstNS r5Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synology.com header.s=123 header.b=DxV6bSAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si2948194jam.93.2021.05.09.19.09.59; Sun, 09 May 2021 19:10:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@synology.com header.s=123 header.b=DxV6bSAL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synology.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230121AbhEJCIE (ORCPT + 99 others); Sun, 9 May 2021 22:08:04 -0400 Received: from mail.synology.com ([211.23.38.101]:42444 "EHLO synology.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230038AbhEJCID (ORCPT ); Sun, 9 May 2021 22:08:03 -0400 Subject: Re: [PATCH v2] block: fix trace completion for chained bio DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1620612418; bh=aiIIs6RGEjdXhexQOGgZusHgo4xHZHZ4r2ou6nC6+hw=; h=Subject:From:To:Cc:References:Date:In-Reply-To; b=DxV6bSALuhocDfV7KPmmIyFWPXk9FYphOwyUZai2Ud06qqb4U8RlJK7DNXRcsF5M7 MBS43dQnZGYA09VLuTYjcYJUPU+6JIiekowRnqJO/e30zo389dmUG9kesAk8aE0gOY ealUGSaVxDfZ+bwPZnqXabzscCUSbeeZxQn7WcXc= From: Edward Hsieh To: NeilBrown , axboe@kernel.dk, neilb@suse.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, s3t@synology.com, bingjingc@synology.com, cccheng@synology.com References: <1614741726-28074-1-git-send-email-edwardh@synology.com> <87zgyudgss.fsf@notabene.neil.brown.name> Message-ID: <10f3e198-f34c-47e9-608a-e5f84e3379a1@synology.com> Date: Mon, 10 May 2021 10:06:57 +0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Synology-MCP-Status: no X-Synology-Spam-Flag: no X-Synology-Spam-Status: score=0, required 6, WHITELIST_FROM_ADDRESS 0 X-Synology-Virus-Status: no Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/23/2021 4:04 PM, Edward Hsieh wrote: > On 3/23/2021 5:22 AM, NeilBrown wrote: >> On Wed, Mar 03 2021, edwardh wrote: >> >>> From: Edward Hsieh >>> >>> For chained bio, trace_block_bio_complete in bio_endio is currently >>> called >>> only by the parent bio once upon all chained bio completed. >>> However, the sector and size for the parent bio are modified in >>> bio_split. >>> Therefore, the size and sector of the complete events might not match >>> the >>> queue events in blktrace. >>> >>> The original fix of bio completion trace ("block: trace >>> completion of all bios.") wants multiple complete events to correspond >>> to one queue event but missed this. >>> >>> md/raid5 read with bio cross chunks can reproduce this issue. >>> >>> To fix, move trace completion into the loop for every chained bio to >>> call. >> >> Thanks.  I think this is correct as far as tracing goes. >> However the code still looks a bit odd. >> >> The comment for the handling of bio_chain_endio suggests that the *only* >> purpose for that is to avoid deep recursion.  That suggests it should be >> at the end of the function. >> As it is blk_throtl_bio_endio() and bio_unint() are only called on the >> last bio in a chain. >> That seems wrong. >> >> I'd be more comfortable if the patch moved the bio_chain_endio() >> handling to the end, after all of that. >> So the function would end. >> >> if (bio->bi_end_io == bio_chain_endio) { >>     bio = __bio_chain_endio(bio); >>     goto again; >> } else if (bio->bi_end_io) >>     bio->bi_end_io(bio); >> >> Jens:  can you see any reason why that functions must only be called on >> the last bio in the chain? >> >> Thanks, >> NeilBrown >> > > Hi Neil and Jens, > > From the commit message, bio_uninit is put here for bio allocated in > special ways (e.g., on stack), that will not be release by bio_free. For > chained bio, __bio_chain_endio invokes bio_put and release the > resources, so it seems that we don't need to call bio_uninit for chained > bio. > > The blk_throtl_bio_endio is used to update the latency for the throttle > group. I think the latency should only be updated after the whole bio is > finished? > > To make sense for the "tail call optimization" in the comment, I'll > suggest to wrap the whole statement with an else. What do you think? > > if (bio->bi_end_io == bio_chain_endio) { >     bio = __bio_chain_endio(bio); >     goto again; > } else { >     blk_throtl_bio_endio(bio); >     /* release cgroup info */ >     bio_uninit(bio); >     if (bio->bi_end_io) >         bio->bi_end_io(bio); > } > > Thanks, > Edward Hsieh Hi Neil and Jens, Any feedback on this one? Thank you, Edward Hsieh