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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11368C4743D for ; Wed, 9 Jun 2021 00:37:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B9450613C3 for ; Wed, 9 Jun 2021 00:37:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9450613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F4E66B006C; Tue, 8 Jun 2021 20:37:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CC1A6B006E; Tue, 8 Jun 2021 20:37:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 294EE6B0070; Tue, 8 Jun 2021 20:37:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id EEC096B006C for ; Tue, 8 Jun 2021 20:37:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 885088249980 for ; Wed, 9 Jun 2021 00:37:12 +0000 (UTC) X-FDA: 78232321104.18.D944C3A Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) by imf23.hostedemail.com (Postfix) with ESMTP id 2BE91A000245 for ; Wed, 9 Jun 2021 00:37:09 +0000 (UTC) Received: by mail-il1-f178.google.com with SMTP id h16so9680529ila.6 for ; Tue, 08 Jun 2021 17:37:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=z9xvYmw13b60K378g+x+OptBkyWgf9AfbCR5AXVFM5Q=; b=pVWgLY7dqIXpdHP0kdyCYjAJ4Y3Ao2iq+ey/TSF54PcD+DvpeIZznNpNWe/Hc9kheR Ipz4p7nUzkx7BEHMDYazMLcpyuKrAG1FtX7gevwVLhMM34XRYMZApZUEZSKgmP9M1k9U 6wrcQPUASgKCk0xGDa2E9iPxtU0V5Tm6OS0sJEnsNq1PQPrNapBLUm84Yq2OUPr62VG/ DW52U2wSn40JntwsqmkTy3Zhlk8RCMr3SrFcI2vnooC7zLd+lSKHke3a5EmrJiNgsffm coa9pZBBu0EW+t/ixGZwB4iWhtwU2gbWtMqRU5DMbojbeuP4kOaTvqO8Q+8XFXkrREJT DM3A== X-Gm-Message-State: AOAM533kmd41fsv0GLMgMP0ySlDFlctevfeq9sty8d2z9KUJVhKAvkIm w8DBUnKo1RW+d2jvB0OgcZA= X-Google-Smtp-Source: ABdhPJya9bbFM8vdeKIdzDKdWIbr8Lb1teNvv6b2Ph//eGKubN2nQ8omGTaOwxmop/DoG9Rh33jelQ== X-Received: by 2002:a92:c704:: with SMTP id a4mr21787667ilp.157.1623199031629; Tue, 08 Jun 2021 17:37:11 -0700 (PDT) Received: from google.com (243.199.238.35.bc.googleusercontent.com. [35.238.199.243]) by smtp.gmail.com with ESMTPSA id a18sm697476ilc.31.2021.06.08.17.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 17:37:11 -0700 (PDT) Date: Wed, 9 Jun 2021 00:37:10 +0000 From: Dennis Zhou To: Roman Gushchin Cc: Andrew Morton , Tejun Heo , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , Jan Kara , Dave Chinner , cgroups@vger.kernel.org Subject: Re: [PATCH v9 8/8] writeback, cgroup: release dying cgwbs by switching attached inodes Message-ID: References: <20210608230225.2078447-1-guro@fb.com> <20210608230225.2078447-9-guro@fb.com> <20210608171237.be2f4223de89458841c10fd4@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of dennisszhou@gmail.com designates 209.85.166.178 as permitted sender) smtp.mailfrom=dennisszhou@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2BE91A000245 X-Stat-Signature: 1zm6wgmkidn87gpgzuf34z6io9uwr7e4 X-HE-Tag: 1623199029-994814 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 Tue, Jun 08, 2021 at 05:23:34PM -0700, Roman Gushchin wrote: > On Tue, Jun 08, 2021 at 05:12:37PM -0700, Andrew Morton wrote: > > On Tue, 8 Jun 2021 16:02:25 -0700 Roman Gushchin wrote: > > > > > Asynchronously try to release dying cgwbs by switching attached inodes > > > to the nearest living ancestor wb. It helps to get rid of per-cgroup > > > writeback structures themselves and of pinned memory and block cgroups, > > > which are significantly larger structures (mostly due to large per-cpu > > > statistics data). This prevents memory waste and helps to avoid > > > different scalability problems caused by large piles of dying cgroups. > > > > > > Reuse the existing mechanism of inode switching used for foreign inode > > > detection. To speed things up batch up to 115 inode switching in a > > > single operation (the maximum number is selected so that the resulting > > > struct inode_switch_wbs_context can fit into 1024 bytes). Because > > > every switching consists of two steps divided by an RCU grace period, > > > it would be too slow without batching. Please note that the whole > > > batch counts as a single operation (when increasing/decreasing > > > isw_nr_in_flight). This allows to keep umounting working (flush the > > > switching queue), however prevents cleanups from consuming the whole > > > switching quota and effectively blocking the frn switching. > > > > > > A cgwb cleanup operation can fail due to different reasons (e.g. not > > > enough memory, the cgwb has an in-flight/pending io, an attached inode > > > in a wrong state, etc). In this case the next scheduled cleanup will > > > make a new attempt. An attempt is made each time a new cgwb is offlined > > > (in other words a memcg and/or a blkcg is deleted by a user). In the > > > future an additional attempt scheduled by a timer can be implemented. > > > > > > ... > > > > > > +/* > > > + * Maximum inodes per isw. A specific value has been chosen to make > > > + * struct inode_switch_wbs_context fit into 1024 bytes kmalloc. > > > + */ > > > +#define WB_MAX_INODES_PER_ISW 115 > > > > Can't we do 1024/sizeof(struct inode_switch_wbs_context)? > > It must be something like > DIV_ROUND_DOWN_ULL(1024 - sizeof(struct inode_switch_wbs_context), sizeof(struct inode *)) + 1 Sorry to keep popping in for 1 offs but maybe this instead? I think the above would result in > 1024 kzalloc() call. DIV_ROUND_DOWN_ULL(max(1024 - sizeof(struct inode_switch_wbs_context), sizeof(struct inode *)), sizeof(struct inode *)) might need max_t not sure. > > But honestly 1024 came out of a thin air too, so I'm not sure it worth it. > I liked the number 128 but then made it fit into the closest kmalloc cache. > > Btw, thank you for picking these patches up! Thanks, Dennis