Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp496934lqo; Fri, 10 May 2024 06:27:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURFSe1HLM/od78oYCrMi2GWZQklPe49zZ22ATBoSq9LRpFod/EV6so4XOZuIZLH1be55UqvHtzyslWSoinAR2M14WWr9jNrYHpttqaLA== X-Google-Smtp-Source: AGHT+IEZA3vDd5nJl1W8Cb86HYn3a2b6QPnjTbJGEn2WhNHDj/jncTL5xETj5e6XCQlpU5kUwMY5 X-Received: by 2002:a05:6a20:6a0e:b0:1af:b0d0:281 with SMTP id adf61e73a8af0-1afde09f71cmr3695497637.6.1715347632419; Fri, 10 May 2024 06:27:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715347632; cv=pass; d=google.com; s=arc-20160816; b=Hy+y4c+1vwCNSyXY2pFi71KhNovf5KtxRIr6liiBbaGdGtkJrINw4m5Ehti4pV07iG h+7AQKklofUGuDgW0IV9SU24YjrhH5DoI/C7g4PGSqlZWwsWHxsNH3AUkPP/1qHCog4S Nm7hBbHl1B1APLVWAzw6nZFaVs2SzDo9F7MOzvZYp3ivMkzMbaFaOnBdTHB4BvlyNNSV kVkrG+iy/4MoD5NeaRJiJYVsaZjpRsvevDIWohpcTpJ9xftoN/+Bi5zfPpLhYNRyVJeq HvTKCQ9DeZuE5EnZpaHC0LG8/jWQG4/JLq3wyAMrcmdHBxZnlbAPV/sQtKCwmIiBFCRE lgpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=1neooF3mgFb2Ddvo0cNo073MdM8ntyg4Z5+TI/To1Kw=; fh=9o9dYtWny8Oc1K9a4TngM0uu0RioCZZGWGzyAmcp9lc=; b=wJ971vqlVrtvHE8LvgmTqu45gFWsR2xJA/z7qyjXRTXM87HABW2a7YF26npKa31W8N l1+lKk3r6+5//BzCLilqsL7NPE0IDBznIAEeVmgsFuJ66Qkea7mOiRNmBt+Ac4hed8Et nkVpvAKtk0MSFWg0WQwHSPchLrSXjWyd6aGrc4CgxmWacEiODLP0RSan6qhqJiS/Do5N dfo+R5hZnS3IonckzIWQZp6g93pyLZvW0PonxXlkEYc73xmKSgnIaVKfDVDLcl1JX3cz XbmwCgIozaiFlmy0KNs5L7T8sWUD8R0viL31AiSiDQbzY45gmJllJcs6VB6OJ542HLgh //7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tbQNBYv1; dkim=pass header.i=@suse.com header.s=susede1 header.b=tbQNBYv1; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-175820-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-634117192casi2507279a12.546.2024.05.10.06.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 06:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175820-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tbQNBYv1; dkim=pass header.i=@suse.com header.s=susede1 header.b=tbQNBYv1; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-175820-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C453BB21794 for ; Fri, 10 May 2024 13:27:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B72B812C486; Fri, 10 May 2024 13:26:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="tbQNBYv1"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="tbQNBYv1" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC95F12BF21 for ; Fri, 10 May 2024 13:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715347611; cv=none; b=IaIEix2LnbMezDANT7L+GFDl1A0eyCvrNyv9Kpx6hiMHc6BK+UuV8Rs6pLGcRvlHHU0XZXNp+nGbeDeKNxRXeTKl/yhoFvRcQnP5Lr8AXnEZNqEl6JuibRTLI5uxoPe/WdByLpML7rMHEVJ8ufCfJ/+iFnOyKaVVNFcChfjzK8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715347611; c=relaxed/simple; bh=Ptqv9/UW3AsNmkl/pJs5+10YJOZ9fx/1CAxitID4Ki0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fl6bi8HHk2Oq56CoLeIfG++1zuIsKLoFqBazaQTmnwzdmizMR1zWDiM/IInaTBVN+GgVYZkDgdBgTBqEhAAs+FweH3P7dVMlwC8KiFakiwRQNi/NAuPNZWUE2juEHxvmHJf0b6TdUKJueaqeJ+QLkgTj+nJAqWUdfMZYMq3tdXE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=tbQNBYv1; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=tbQNBYv1; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DA54D3EE5F; Fri, 10 May 2024 13:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1715347607; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1neooF3mgFb2Ddvo0cNo073MdM8ntyg4Z5+TI/To1Kw=; b=tbQNBYv1lmYZAGyalO4mAfwP7QwGulUxps7d9B0PgH0qvlMmlyg5MXTDCllCtazbcrzawM rhn4MWki0abWLgsRsxbIIjoZYZOLIwxKnV7mgFiFzAa3fygHB9+v+Ei87EK7WHkTmgPJty rhTdQ7hPX8HYsu6AVEU4MWcE5hvP3ws= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1715347607; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1neooF3mgFb2Ddvo0cNo073MdM8ntyg4Z5+TI/To1Kw=; b=tbQNBYv1lmYZAGyalO4mAfwP7QwGulUxps7d9B0PgH0qvlMmlyg5MXTDCllCtazbcrzawM rhn4MWki0abWLgsRsxbIIjoZYZOLIwxKnV7mgFiFzAa3fygHB9+v+Ei87EK7WHkTmgPJty rhTdQ7hPX8HYsu6AVEU4MWcE5hvP3ws= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9EE82139AA; Fri, 10 May 2024 13:26:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id rS1BApYgPmaMBAAAD6G6ig (envelope-from ); Fri, 10 May 2024 13:26:46 +0000 Date: Fri, 10 May 2024 15:26:35 +0200 From: Michal Hocko To: Roman Gushchin Cc: Andrew Morton , Muchun Song , Johannes Weiner , Shakeel Butt , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH rfc 6/9] mm: memcg: move cgroup v1 oom handling code into memcontrol-v1.c Message-ID: References: <20240509034138.2207186-1-roman.gushchin@linux.dev> <20240509034138.2207186-7-roman.gushchin@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240509034138.2207186-7-roman.gushchin@linux.dev> X-Spam-Level: X-Spamd-Result: default: False [-2.44 / 50.00]; BAYES_HAM(-1.64)[92.72%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_VIA_SMTP_AUTH(0.00)[]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Spam-Score: -2.44 X-Spam-Flag: NO On Wed 08-05-24 20:41:35, Roman Gushchin wrote: [...] > @@ -1747,106 +1623,14 @@ static bool mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) > > memcg_memory_event(memcg, MEMCG_OOM); > > - /* > - * We are in the middle of the charge context here, so we > - * don't want to block when potentially sitting on a callstack > - * that holds all kinds of filesystem and mm locks. > - * > - * cgroup1 allows disabling the OOM killer and waiting for outside > - * handling until the charge can succeed; remember the context and put > - * the task to sleep at the end of the page fault when all locks are > - * released. > - * > - * On the other hand, in-kernel OOM killer allows for an async victim > - * memory reclaim (oom_reaper) and that means that we are not solely > - * relying on the oom victim to make a forward progress and we can > - * invoke the oom killer here. > - * > - * Please note that mem_cgroup_out_of_memory might fail to find a > - * victim and then we have to bail out from the charge path. > - */ > - if (READ_ONCE(memcg->oom_kill_disable)) { > - if (current->in_user_fault) { > - css_get(&memcg->css); > - current->memcg_in_oom = memcg; > - current->memcg_oom_gfp_mask = mask; > - current->memcg_oom_order = order; > - } > + if (!mem_cgroup_v1_oom_prepare(memcg, mask, order, &locked)) > return false; > - } > - > - mem_cgroup_mark_under_oom(memcg); > - > - locked = mem_cgroup_oom_trylock(memcg); This really confused me because this looks like the oom locking is removed for v2 but this is not the case because mem_cgroup_v1_oom_prepare is not really v1 only code - in other words this is not going to be just return false for CONFIG_MEMCG_V1=n. It makes sense to move the userspace oom handling out to the v1 file. I would keep mem_cgroup_mark_under_oom here. I am not sure about the oom locking thing because I think we can make it v1 only. For v2 I guess we can go without this locking as the oom path is already locked and it implements overkilling prevention (oom_evaluate_task) as it walks all processes in the oom hierarchy. > - > - if (locked) > - mem_cgroup_oom_notify(memcg); > - > - mem_cgroup_unmark_under_oom(memcg); > ret = mem_cgroup_out_of_memory(memcg, mask, order); > - > - if (locked) > - mem_cgroup_oom_unlock(memcg); > + mem_cgroup_v1_oom_finish(memcg, &locked); > > return ret; > } -- Michal Hocko SUSE Labs