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 691B5C3DA60 for ; Thu, 18 Jul 2024 09:25:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8EFC6B0088; Thu, 18 Jul 2024 05:25:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3EEC6B008C; Thu, 18 Jul 2024 05:25:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D06956B0092; Thu, 18 Jul 2024 05:25:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B22166B0088 for ; Thu, 18 Jul 2024 05:25:51 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 509BA4197B for ; Thu, 18 Jul 2024 09:25:51 +0000 (UTC) X-FDA: 82352341302.19.69E2671 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by imf12.hostedemail.com (Postfix) with ESMTP id 4ED064001A for ; Thu, 18 Jul 2024 09:25:49 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=IwxaPrde; spf=pass (imf12.hostedemail.com: domain of mhocko@suse.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721294728; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+AQXyp5zTd9VUi1GRGHEcdKdd16XlM0Bs2GIA+qkJx8=; b=7aDqRWYbP+V03qU8VgETs66BrTdOAS0fLnzFnKfprxk/mqpc+05SbispVLgR8WqPZjJ1ux l6zo5S1tzi2ezjqRMcC3OHULuU4oMvZHyiMixE4qQXA4J9uisSzstvaz3Z8VJSR7ppHQu/ alNeh76qhPIMt8ohDDpfuquxWJqDrmM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=IwxaPrde; spf=pass (imf12.hostedemail.com: domain of mhocko@suse.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721294728; a=rsa-sha256; cv=none; b=jFoJ2Zn5H0QPkdPMHYtDCUYKmhrQDPWvpYycnt/u6dRolJ3sATSWmBMvwaepcXQ/IKO3Jd xNzfSVtMjO0SJDw/8bqOiwkCaSGTIjMWxG7A9XrjfSlNRQ+tf9szEfnBbJTz2u4k9u7KZK EBHroBVGd/A1wUUH7h0MFTLSQNoc+7s= Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5a156557029so588088a12.2 for ; Thu, 18 Jul 2024 02:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1721294748; x=1721899548; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=+AQXyp5zTd9VUi1GRGHEcdKdd16XlM0Bs2GIA+qkJx8=; b=IwxaPrdefGvyxZl/UD5TKqMU6gBsB6oWp1AcJeC1KE1q28sR/yRqtQka/BufGeWeaO po++yT4nmPyFFn5oID+tLgRl8vCwIAOGu0b4H7orwIJeeBeGdjBzqs0u2Hby9gOl194g DWZ38Zw58lh02xP53R+XmPpSCUO4VMoo80WMKFxLtaSCYBVL8RtDRRauCSEq5jdo5RHQ bLVyRBvycWOBMGmvfpzaaR5tKbqTP7UW4F1MocUNg1QPgfeSEBXPaLI9NoUS0iodFHJP pFVLpuNbnULnPBy7etLuA0xZzTKZTd11SU6Zgudgw1jspGM7CwqJCuDmrTNPh18jGEFt BG0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721294748; x=1721899548; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+AQXyp5zTd9VUi1GRGHEcdKdd16XlM0Bs2GIA+qkJx8=; b=aE0iWH9YNNTAgMzMSlabl+7mqi4F35UX7klw0UU0vlsE4mpatmdZkmgtLIA25gnbfr i5WAJDGYFK7JpX3FwVqlklLlOuYLq5UZtzpkOALcnywRUL4nKsyDKPSDxXV6pGJ2CiMh aDZFO+VCQtn4xCYOXQS4ArLJqLn15MXP7owkTTSUQ0BszMj4jB/8WXIQIsFxDgAuprmH DUIE1oZRcCbR7ADVlr6C3+mjV6yeZaO5eoHU/Utj6NIxcs8ERvJaN0prc4FDjwm+nV/8 WNdGibbVUFk4km1SFCD75oH+uXlOGdA5/umEFoktrxnPJUkGBWPl2/GQemjVpA79Ydzi Z+ag== X-Forwarded-Encrypted: i=1; AJvYcCWrUCKXwlQhENmLtDamihe9VZgITa7aUsYF8sqJcVflR1zz1fVQ/6VvB2BOs61fW1dpRQkDhFeusQwHvZ1IyJlmXaA= X-Gm-Message-State: AOJu0YxDPlLzcWT+ivwh/EwsLgr7RYD5IL2e6joc+oirdJVDGaBtCZlU LMK0CCPI41n4XVWYb/6U+NoALf0k4DYQva1rEH4o7QPoRS1aVYjc39zWojCrt7s= X-Google-Smtp-Source: AGHT+IFcIaqSCi+C+Us2/WOlLLOFk4vnRTB+ewPkaisAHCGngBiHg0I8w89X2OGpWh4lJCiAB53pmw== X-Received: by 2002:a17:906:3b87:b0:a6f:593f:d336 with SMTP id a640c23a62f3a-a7a01138dd4mr273782966b.11.1721294747674; Thu, 18 Jul 2024 02:25:47 -0700 (PDT) Received: from localhost (109-81-94-157.rct.o2.cz. [109.81.94.157]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc7ff61bsm544875666b.166.2024.07.18.02.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:25:47 -0700 (PDT) Date: Thu, 18 Jul 2024 11:25:46 +0200 From: Michal Hocko To: Qu Wenruo Cc: "Vlastimil Babka (SUSE)" , Qu Wenruo , linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Cgroups , Matthew Wilcox Subject: Re: [PATCH 0/2] mm: skip memcg for certain address space Message-ID: References: <8faa191c-a216-4da0-a92c-2456521dcf08@kernel.org> <9c0d7ce7-b17d-4d41-b98a-c50fd0c2c562@gmx.com> <9572fc2b-12b0-41a3-82dc-bb273bfdd51d@kernel.org> <304fdaa9-81d8-40ae-adde-d1e91b47b4c0@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 4ED064001A X-Stat-Signature: br1wty4brgp5ggbhxyydpaq1t4zggwep X-Rspam-User: X-HE-Tag: 1721294749-18110 X-HE-Meta: U2FsdGVkX18gLybxwU8gjynEB5zzT3ZoN75nu52lOQNHZxkwoECPAmgXYNY0eiCGZcXK2Zk5jokK4nhvCB5KOLlqOeaCwa6MtYenCTw11J2DRAYt1FNsjG4lLFamIVxQ0PMhXy5gP26ougz6oF9bs1Y0gimwVGPPZIfnFj0Etp9eBJT5WCMO4o/CpHcjcQEgS05A94ldZA5vFPT2pMrUK0loASL+l3a/n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ests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu 18-07-24 18:22:11, Qu Wenruo wrote: > > > 在 2024/7/18 17:39, Michal Hocko 写道: > > On Thu 18-07-24 17:27:05, Qu Wenruo wrote: > > > > > > > > > 在 2024/7/18 16:55, Michal Hocko 写道: > > > > On Thu 18-07-24 09:17:42, Vlastimil Babka (SUSE) wrote: > > > > > On 7/18/24 12:38 AM, Qu Wenruo wrote: > > > > [...] > > > > > > Does the folio order has anything related to the problem or just a > > > > > > higher order makes it more possible? > > > > > > > > > > I didn't spot anything in the memcg charge path that would depend on the > > > > > order directly, hm. Also what kernel version was showing these soft lockups? > > > > > > > > Correct. Order just defines the number of charges to be reclaimed. > > > > Unlike the page allocator path we do not have any specific requirements > > > > on the memory to be released. > > > > > > So I guess the higher folio order just brings more pressure to trigger the > > > problem? > > > > It increases the reclaim target (in number of pages to reclaim). That > > might contribute but we are cond_resched-ing in shrink_node_memcgs and > > also down the path in shrink_lruvec etc. So higher target shouldn't > > cause soft lockups unless we have a bug there - e.g. not triggering any > > of those paths with empty LRUs and looping somewhere. Not sure about > > MGLRU state of things TBH. > > > > > > And finally, even without the hang problem, does it make any sense to > > > > > > skip all the possible memcg charge completely, either to reduce latency > > > > > > or just to reduce GFP_NOFAIL usage, for those user inaccessible inodes? > > > > > > > > Let me just add to the pile of questions. Who does own this memory? > > > > > > A special inode inside btrfs, we call it btree_inode, which is not > > > accessible out of the btrfs module, and its lifespan is the same as the > > > mounted btrfs filesystem. > > > > But the memory charge is attributed to the caller unless you tell > > otherwise. > > By the caller, did you mean the user space program who triggered the > filesystem operations? Yes, the current task while these operations are done. [...] > > So if this is really an internal use and you use a shared > > infrastructure which expects the current task to be owner of the charged > > memory then you need to wrap the initialization into set_active_memcg > > scope. > > > > And for root cgroup I guess it means we will have no memory limits or > whatever, and filemap_add_folio() should always success (except real -ENOMEM > situations or -EEXIST error btrfs would handle)? Yes. try_charge will bypass charging altogether for root cgroup. You will likely need to ifdef root_mem_cgroup usage by CONFIG_MEMCG. -- Michal Hocko SUSE Labs