Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5137865pxj; Wed, 9 Jun 2021 10:00:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2Jx4rsmt6NF2EiRyiLMZBED8ZX922EFRKV5yxx8tRq/OhNWSxcJPGdUA9PNeRJk5TugRs X-Received: by 2002:a17:906:f9d1:: with SMTP id lj17mr785758ejb.345.1623258012657; Wed, 09 Jun 2021 10:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623258012; cv=none; d=google.com; s=arc-20160816; b=pMGmqCpmVRAPllO98ux4BzkpaxN8VP00JSblUbNYNsCGs/yhajgs/pLTZm8B+tDDoB uwYP8AC967hQpCJSzx+5z6en5EXnBLjI1pOZkclnbrt8/VSDSD9fTlvTMRG0HouE7GRu nnDk4W13eNXk3sauVSg1dW7h0Uub7U7KklbjnpmBW+vbqV2DTmouufGyVV978NpTNNz3 FXrmIoF9PtPVhO8P8eZTp4qCZ4ttLlnBR59SPAi0/dZDph7FKQfVRt+YVdhOGQ/0WiuP zDEQANGmimR6KuTIZque1eJ5JbudJfddvbxpcY5XNRaGR3AQNZTkmChwEROvsmA+3jy1 m7AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=z9xvYmw13b60K378g+x+OptBkyWgf9AfbCR5AXVFM5Q=; b=hl/gLHpjzcv9McVW2k1MjWiNxjwfKW9rICfYzN0oL9Hc1LtLyvkvYDpJwNxGvLO01O Lm0Qet1Lwac4hub76e1So3rnmJeKU5jH+vWYrCzqDd6w9uwgoQrrh+w/M7yKkFCwAGVt LMDU/keHKZ9v2D5U+GiQthuTJe/RBzSzrDtlVj2ylC9BiUN4oO3W2fFvVfJ3nnba8r9Y juj34nLMZ0SaJ2ys6dJoOlY3Wb5DchALOPPAKrvDw7w4SHC7lqKn3ny9BLGDdThbyB09 5V7d4dI/ihD16snWU8J2gpRTDUxsWBBGK8zqjgYnfCiNb+RYvmvwYw2UeDOW53FESGRD r4kA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b16si215008edw.36.2021.06.09.09.59.48; Wed, 09 Jun 2021 10:00:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232560AbhFIAjG (ORCPT + 99 others); Tue, 8 Jun 2021 20:39:06 -0400 Received: from mail-il1-f170.google.com ([209.85.166.170]:35392 "EHLO mail-il1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232202AbhFIAjF (ORCPT ); Tue, 8 Jun 2021 20:39:05 -0400 Received: by mail-il1-f170.google.com with SMTP id b9so22395612ilr.2; Tue, 08 Jun 2021 17:37:11 -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=Bdk2keqKmepkOviS2h7YcK3ugh5FZB9Pad8h3E6LaYpmIswBb28HN5cKX0dToXpVwG pZ+65Yw8jpkkz1Ik2e5V4Hf1LjwQLRgLphvChq5zhRT6XwXyjd2bFfidVWR7DoAbdwhF BQZVImIkVaTOZfy5hEdGiJxdXnyXR3+gQj5Ak4CW9Dee2O6wjeOFLaLmuS9N3xTpBrxx s8YP0fBiRl/fDS15dUCBag2obukDgUKEMvSVyYz11SC7zt1AryQxnFNUj8s6lJadAwOf pg6xk0giIPmjtMqmp4SvAgeYDzY9A0SQW3XsLS1nDoVlSX1UXgFYmtE6bHVQzm26Mgk6 1ZRw== X-Gm-Message-State: AOAM531wgX3iTj7LyfWu4/6JZpZWEQc+eJRzZX6ILrgfpm6qGFZPJT8j gtAL7OTyq4rzCaGp+0dVcZ8= 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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