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 6ED6BC77B7F for ; Fri, 5 May 2023 15:18:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B4AC6B0080; Fri, 5 May 2023 11:18:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0635F6B007E; Fri, 5 May 2023 11:18:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E95656B0080; Fri, 5 May 2023 11:18:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by kanga.kvack.org (Postfix) with ESMTP id C38B56B007D for ; Fri, 5 May 2023 11:18:31 -0400 (EDT) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1a5197f00e9so13585355ad.1 for ; Fri, 05 May 2023 08:18:31 -0700 (PDT) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; 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 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ifGe5SCBl6LiTmaKB6IMHqgE/UQtwA/JCHyZLwepmFs=; b=Cm+jxMluvj97Rk6DjMEiXdMFC1aVd2waQ4E5Hkk3JwB6WXVbwhR00bOUx0C3JMRPSW U3mU/kK94TS4F/Alay0/nlb/5AiubPorxPXA2GoKPlA+zmxFX9/JkcrdV+81qVkbUfi0 ZQN+40au0wa4HQo+okN6a/Z/63rtvp8jSH6WDWJ8iDwNJOVc7j9W3fXtcIvP88oj6rjb quafyOKT2mtyO8CMAz6t6jPFwnWMgGGACSxVCOLDrnjJR/X4+P4T389mfmY+fTIdgq7p Xnh3JwQ/LFnscIJhX41ei3s2QQPNr8NKn8lnBXwGhQk/v7wTTnDilXIWQ2BxHhZY9Znq xI3Q== X-Gm-Message-State: AC+VfDwBKw5WAgqvrprWDjTe2N190MYN7T0IlzlJ/MP7DIWlzD+i5LWA kWsPkmuQjq4pUcDgb+5LV5w= X-Google-Smtp-Source: ACHHUZ52SvHzNYSS03JP+px8g4n9TWTr5boTMz6H2G0M0V35JmKb9GdqAxbp2/TvvQ4FIojhgqiYFQ== X-Received: by 2002:a17:902:a583:b0:1aa:f818:7a23 with SMTP id az3-20020a170902a58300b001aaf8187a23mr1917554plb.27.1683299910592; Fri, 05 May 2023 08:18:30 -0700 (PDT) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id z12-20020a170903018c00b001aae64e9b36sm1936479plg.114.2023.05.05.08.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 08:18:30 -0700 (PDT) Date: Fri, 5 May 2023 05:18:28 -1000 From: Tejun Heo 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@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v5 1/5] writeback: move wb_over_bg_thresh() call outside lock section Message-ID: References: <20230421174020.2994750-1-yosryahmed@google.com> <20230421174020.2994750-2-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230421174020.2994750-2-yosryahmed@google.com> 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, 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. > > 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. > > Signed-off-by: Yosry Ahmed > Reviewed-by: Michal Koutný > Reviewed-by: Jan Kara Acked-by: Tejun Heo Thanks. -- tejun