From: Tejun Heo Subject: Re: [PATCH v5 1/5] writeback: move wb_over_bg_thresh() call outside lock section Date: Fri, 5 May 2023 05:18:28 -1000 Message-ID: References: <20230421174020.2994750-1-yosryahmed@google.com> <20230421174020.2994750-2-yosryahmed@google.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683299911; x=1685891911; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :from:to:cc:subject:date:message-id:reply-to; bh=ifGe5SCBl6LiTmaKB6IMHqgE/UQtwA/JCHyZLwepmFs=; b=LOCvxoCYnbO8vSFTDuslVAoHxOxcX15yndsKlnUvr2wTVi5GO8cUn6SH8zrFLLfgKj gctVe7W4+OfqT7r+1idRiG/ru/roEMb6dNrPfky5N9RPinDVOJR3alCNfoDv321FKcok GeA+J/uYdMExiKiTKCoyKPGYVr+oQbnl3liZu+wD5qnu+CWQ0QfcPpjO3ir5/1a9fyX9 NQnXKFocgv2gOwhxEbwbiroRzVebgIWY50njUAsUYR3Wf+B4+ondcckCIzTiX2HLB/Og GdYQfKOrWu/ZZhRLoL8huAgdkqz+9WEIokjox6VecuQoiQttNEmUd4E8QYbgAKC1usGg HG3g== Sender: Tejun Heo Content-Disposition: inline In-Reply-To: <20230421174020.2994750-2-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> List-ID: Content-Type: text/plain; charset="iso-8859-1" To: Yosry Ahmed Cc: Alexander Viro , Christian Brauner , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Jan Kara , Jens Axboe , Michal =?iso-8859-1?Q?Koutn=FD?= , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org On Fri, Apr 21, 2023 at 05:40:16PM +0000, Yosry Ahmed wrote: > wb_over_bg_thresh() calls mem_cgroup_wb_stats() which invokes an rstat > flush, which can be expensive on large systems. Currently, > wb_writeback() calls wb_over_bg_thresh() within a lock section, so we > have to do the rstat flush atomically. On systems with a lot of > cpus and/or cgroups, this can cause us to disable irqs for a long time, > potentially causing problems. >=20 > Move the call to wb_over_bg_thresh() outside the lock section in > preparation to make the rstat flush in mem_cgroup_wb_stats() non-atomic. > The list_empty(&wb->work_list) check should be okay outside the lock > section of wb->list_lock as it is protected by a separate lock > (wb->work_lock), and wb_over_bg_thresh() doesn't seem like it is > modifying any of wb->b_* lists the wb->list_lock is protecting. > Also, the loop seems to be already releasing and reacquring the > lock, so this refactoring looks safe. >=20 > Signed-off-by: Yosry Ahmed > Reviewed-by: Michal Koutn=FD > Reviewed-by: Jan Kara Acked-by: Tejun Heo Thanks. --=20 tejun