From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755544AbdJIWmV (ORCPT ); Mon, 9 Oct 2017 18:42:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56924 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755259AbdJIWmQ (ORCPT ); Mon, 9 Oct 2017 18:42:16 -0400 Date: Mon, 9 Oct 2017 15:42:12 -0700 From: Andrew Morton To: Yafang Shao Cc: jack@suse.cz, mhocko@suse.com, hannes@cmpxchg.org, vdavydov.dev@gmail.com, jlayton@redhat.com, nborisov@suse.com, tytso@mit.edu, mawilcox@microsoft.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jens Axboe Subject: Re: [PATCH] mm/page-writeback.c: fix bug caused by disable periodic writeback Message-Id: <20171009154212.bdf3645a2dce5d540657914b@linux-foundation.org> In-Reply-To: <1507330684-2205-1-git-send-email-laoar.shao@gmail.com> References: <1507330684-2205-1-git-send-email-laoar.shao@gmail.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 7 Oct 2017 06:58:04 +0800 Yafang Shao wrote: > After disable periodic writeback by writing 0 to > dirty_writeback_centisecs, the handler wb_workfn() will not be > entered again until the dirty background limit reaches or > sync syscall is executed or no enough free memory available or > vmscan is triggered. > So the periodic writeback can't be enabled by writing a non-zero > value to dirty_writeback_centisecs > As it can be disabled by sysctl, it should be able to enable by > sysctl as well. > > ... > > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -1972,7 +1972,13 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb) > int dirty_writeback_centisecs_handler(struct ctl_table *table, int write, > void __user *buffer, size_t *length, loff_t *ppos) > { > - proc_dointvec(table, write, buffer, length, ppos); > + unsigned int old_interval = dirty_writeback_interval; > + int ret; > + > + ret = proc_dointvec(table, write, buffer, length, ppos); > + if (!ret && !old_interval && dirty_writeback_interval) > + wakeup_flusher_threads(0, WB_REASON_PERIODIC); > + > return 0; We could do with a code comment here, explaining why this code exists. And... I'm not sure it works correctly? For example, if a device doesn't presently have bdi_has_dirty_io() then wakeup_flusher_threads() will skip it and the periodic writeback still won't be started? (why does the dirty_writeback_interval==0 special case exist, btw? Seems to be a strange thing to do). (and what happens if the interval was set to 1 hour and the user rewrites that to 1 second? Does that change take 1 hour to take effect?)