From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 587F5C433F5 for ; Fri, 10 Dec 2021 21:36:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 655326B0072; Fri, 10 Dec 2021 16:35:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DCC86B0073; Fri, 10 Dec 2021 16:35:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47D7D6B0074; Fri, 10 Dec 2021 16:35:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id 3233D6B0072 for ; Fri, 10 Dec 2021 16:35:59 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E4E88181AEF3F for ; Fri, 10 Dec 2021 21:35:48 +0000 (UTC) X-FDA: 78903191976.13.4242E66 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf14.hostedemail.com (Postfix) with ESMTP id 06EF2100007 for ; Fri, 10 Dec 2021 21:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xLcTRcfeExjVcb0aDcdTvIV4ZyO1h30v0m+obLMYKyk=; b=nRJqOqgt0o8kaioB+bITWEQZoP lB4pu53lY451eCDKpjRtMzsMTvwOTgBNF5Q+yHN4eFFLXb+3sWJcetdKp+WYmDVFnu8JpXwMRzAqh q3kzrWgUEUxg9gWWSOR+dZ8aVsmCz0/xAmUpixsHmJERqZlB7qm9UNsxs2iPfemRsRGG4x8wNiedx ZvvGUxkiqw/6yD7WwigKNdneKkcbsWaBLfknP24gD4Tsbqa+WunxIyoiP10v0kNIX2B5erZWmuq8y hrL4faJrQKNn0+VbchT+jROXHNhJyRSH+ZB1UjB1XAvz9PZnkjn49V7IIvqC13YyFufuaax4Ie9ax PBRC477w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvnYJ-000cva-DW; Fri, 10 Dec 2021 21:35:41 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A5C433002C5; Fri, 10 Dec 2021 22:35:37 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 90A952C555173; Fri, 10 Dec 2021 22:35:37 +0100 (CET) Date: Fri, 10 Dec 2021 22:35:37 +0100 From: Peter Zijlstra To: Matthew Wilcox Cc: Andrew Morton , Christoph Hellwig , Manjong Lee , linux-mm@kvack.org, linux-kernel@vger.kernel.org, seunghwan.hyun@samsung.com, sookwan7.kim@samsung.com, nanich.lee@samsung.com, yt0928.kim@samsung.com, junho89.kim@samsung.com, jisoo2146.oh@samsung.com Subject: Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister Message-ID: References: <20211021161942.5983-1-mj0123.lee@samsung.com> <20211021194530.1fabf4fa45cfe3bee6598484@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 06EF2100007 X-Stat-Signature: t9nnbyrq8wfx3dnzc3pjb76fc4er1dkc Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=nRJqOqgt; spf=none (imf14.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none X-HE-Tag: 1639172145-90215 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 22, 2021 at 03:58:13AM +0100, Matthew Wilcox wrote: > On Thu, Oct 21, 2021 at 07:45:30PM -0700, Andrew Morton wrote: > > On Thu, 21 Oct 2021 13:01:30 +0100 Matthew Wilcox wrote: > > > > > On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote: > > > > On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote: > > > > > Because when sdcard is removed, bdi_min_ratio value will remain. > > > > > Currently, the only way to reset bdi_ min_ratio is to reboot. > > > > > > > > But bdis that are unregistered are never re-registered. What is > > > > the problem you're trying to solve? > > > > > > The global bdi_min_ratio needs to be adjusted. See > > > bdi_set_min_ratio() in mm/page-writeback.c. > > > > I added cc:stable to this and tweaked the comment & coding style a bit: > > Definitely improvements on that front. > > I don't know the BDI code particularly well, and the implementation of > bdi_set_min_ratio() confuses me, so I can't say whether the original > patch is clearly correct or not. Looks like something I might've written :-) I'm thinking the part: min_ratio -= bdi->min_ratio; if (bdi_min_ratio + min_ratio < 100) { bdi_min_ratio += min_ratio; bdi->min_ratio += min_ratio; } is what confuses? particularly when min_ratio < bdi->min_ratio? Anyway, two cases: bdi->min_ratio < min_ratio and bdi->min_ratio > min_ratio, let's do both with 0 and 10. bdi->min_ratio = 0, min_ratio = 10 gives us: min_ratio -= bdi->min_ratio; // 10 -= 0 == 10 if (bdi_min_ratio + min_ratio < 100) { // x + 10 < 100 bdi_min_ratio += min_ratio; // x += 10 bdi->min_ratio += min_ratio // 0 += 10 == 10 } The other way around, bdi->min_raito = 10, min_ratio = 0: min_ratio -= bdi->min_ratio; // 0 -= 10 == -10 if (bdi_min_ratio + min_ratio < 100) { // x + -10 < 100 bdi_min_ratio += min_ratio; // x += -10 bdi->min_ratio += min_ratio; // 10 += -10 == 0 } Makes sense?