Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp484633ybm; Thu, 28 May 2020 07:48:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyagssowGwkS0MhKdfh8JCaPX7K3q/5oI2gVbTtU61Uj1tF69bEXfUMmK+8VVV0hvG9yVgZ X-Received: by 2002:a50:ec0d:: with SMTP id g13mr3483660edr.296.1590677305468; Thu, 28 May 2020 07:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590677305; cv=none; d=google.com; s=arc-20160816; b=j3p9mTiN2cK5SrdCzRK/u2GblF6rLGcO6A3QdKJLRcWvWEAbF4P42d4uF83a/yfmxm uEI7dLmiJL/TmpLmfTzNDCAV895kgLJRasSgLaxcJ4E743SwjEqA39tEWQsRaxl+4hqo MdKYbIgYHEvIpISCC9t+bSD4oCocEeP/cKkNjwDIbshTlEnwpefB3Dn6TZPnwwkjzyQu 2NM92Sd+W5h3iQA0lH2eZ5beNfJNO582yvsSWTTouiyFI2mDrORMorB7Sib0DfQve8fW C5viaGbuIoIf8ga+P/YGLPe5sUJiCaWwEBcz8B36J8Lvp15kN5HEIHd8+EmjclRvdUSd E3AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=yH0GK6C7g/Z2BB8qZtsa+N3O0g4K6ozQRNohWO9UtPA=; b=oJsa30b5PZdDzSGUUtj4gwBwgSpunyH/PmkYXo++uYjx7Lcn3nTD/1kuuAYwFjcA/P 1rvk1BXF1eWwv96fhvVCAro+7v1Fc79zpCRKvoGxPGxkJ6Rjh/x4ObNkh2y4BiAh1K+A Fjk6kH0h194dtzQUqa7Fzeb0qwSwtWhjv/cSmImv2joiBKLtv/1N8LBhyGK+OFZbL3uj no23p+Gebmv7Dv7BtOKArbta3dPmXoqoJhIQTVws9huGGz2NDeV21N/6v9/eaiD9T/zc xKpk6KeRoBz3ZfF/zhJNOgnS+0Z5mFjRzI70hbcL7r5OrMWy675A7zKaGLjrEkqUxIHF 1INQ== 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 39si3940687edq.195.2020.05.28.07.47.55; Thu, 28 May 2020 07:48:25 -0700 (PDT) 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 S1728482AbgE1Oru (ORCPT + 99 others); Thu, 28 May 2020 10:47:50 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:53391 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728456AbgE1Ort (ORCPT ); Thu, 28 May 2020 10:47:49 -0400 Received: from callcc.thunk.org (pool-100-0-195-244.bstnma.fios.verizon.net [100.0.195.244]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 04SElk9h006091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 May 2020 10:47:47 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 731D2420304; Thu, 28 May 2020 10:47:46 -0400 (EDT) Date: Thu, 28 May 2020 10:47:46 -0400 From: "Theodore Y. Ts'o" To: Alex Zhuravlev Cc: "linux-ext4@vger.kernel.org" Subject: Re: [PATCH 1/2] ext4: mballoc - prefetching for bitmaps Message-ID: <20200528144746.GE228632@mit.edu> References: <262A2973-9B2D-4DBE-8752-67E91D52C632@whamcloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <262A2973-9B2D-4DBE-8752-67E91D52C632@whamcloud.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, May 15, 2020 at 10:07:06AM +0000, Alex Zhuravlev wrote: > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -2127,6 +2127,96 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac, > return 0; > } > > +/* > + * each allocation context (i.e. a thread doing allocation) has own > + * sliding prefetch window of @s_mb_prefetch size which starts at the > + * very first goal and moves ahead of scaning. > + * a side effect is that subsequent allocations will likely find > + * the bitmaps in cache or at least in-flight. > + */ > +static void > +ext4_mb_prefetch(struct ext4_allocation_context *ac, > + ext4_group_t start) > +{ > + struct super_block *sb = ac->ac_sb; > + ext4_group_t ngroups = ext4_get_groups_count(sb); > + struct ext4_sb_info *sbi = EXT4_SB(sb); > + struct ext4_group_info *grp; > + ext4_group_t nr, group = start; > + struct buffer_head *bh; > + > + /* limit prefetching at cr=0, otherwise mballoc can > + * spend a lot of time loading imperfect groups */ > + if (ac->ac_criteria < 2 && ac->ac_prefetch_ios >= sbi->s_mb_prefetch_limit) > + return; > + > + /* batch prefetching to get few READs in flight */ > + nr = ac->ac_prefetch - group; > + if (ac->ac_prefetch < group) > + /* wrapped to the first groups */ > + nr += ngroups; > + if (nr > 0)I > + return; > + BUG_ON(nr < 0); What are you trying to do here? If nr > 0, we return; if nr < 0, we BUG() --- but nr is an unsigned int, so we never can trigger --- which was the warning reported by the kbuild test bot. So we will only get past this point if ac_prefetch == group. But ac_prefetch appears to be the last group that we prefetched, so it's not clear that the logic is correct here. - Ted