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 BB7A4C433EF for ; Sat, 20 Nov 2021 05:02:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E8366B0071; Sat, 20 Nov 2021 00:01:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 398B26B0072; Sat, 20 Nov 2021 00:01:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 286E36B0073; Sat, 20 Nov 2021 00:01:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 1A0C16B0071 for ; Sat, 20 Nov 2021 00:01:50 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C6D0F82F370F for ; Sat, 20 Nov 2021 05:01:39 +0000 (UTC) X-FDA: 78828110718.07.AAB09EB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 1A63D6001AB0 for ; Sat, 20 Nov 2021 05:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=fON0lxkCCP3L75Wlm+2KB5r1mpxAWywMnz/1PRTo2iM=; b=cyiAIP+nN8cwtnO8uxOeds523R f8WPqgcHmubx387ec5SOjSZENwDl3h5TXBUCRayzgpMEG+nLpiiOmP62Dk52G5DK+JGBpV6Wsl6CG wkWyUd6CFeBWXymjRkzj1MUPEQVWCjc8i7fwmQ8M+ttsYdI77dcpDemYghZ8Vpf/OhJ9yy0f83Hj6 0Enz1uButE8EqMn+02rZJTRB1waVikL+pC4uikfLYvC8Pi/IM7xxHCNeLGWB1qs24suLITEZnkhLb 3MCeG7nRIlV9ODi20SiIpQAWoiYfU15MSdzTM71S0BLS4nQR+BrS6oD0XZWitLFrhdTHLYpalprYU z6lzyMhw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1moIV5-00AEt9-Cv; Sat, 20 Nov 2021 05:01:19 +0000 Date: Sat, 20 Nov 2021 05:01:19 +0000 From: Matthew Wilcox To: Mina Almasry Cc: Jonathan Corbet , Alexander Viro , Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , Hugh Dickins , Shuah Khan , Shakeel Butt , Greg Thelen , Dave Chinner , Roman Gushchin , Theodore Ts'o , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v4 0/4] Deterministic charging of shared memory Message-ID: References: <20211120045011.3074840-1-almasrymina@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211120045011.3074840-1-almasrymina@google.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1A63D6001AB0 X-Stat-Signature: ck5gwz1brzset7yjzt8fotgycu6za9hg Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cyiAIP+n; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1637384497-81349 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, Nov 19, 2021 at 08:50:06PM -0800, Mina Almasry wrote: > 1. One complication to address is the behavior when the target memcg > hits its memory.max limit because of remote charging. In this case the > oom-killer will be invoked, but the oom-killer may not find anything > to kill in the target memcg being charged. Thera are a number of considerations > in this case: > > 1. It's not great to kill the allocating process since the allocating process > is not running in the memcg under oom, and killing it will not free memory > in the memcg under oom. > 2. Pagefaults may hit the memcg limit, and we need to handle the pagefault > somehow. If not, the process will forever loop the pagefault in the upstream > kernel. > > In this case, I propose simply failing the remote charge and returning an ENOSPC > to the caller. This will cause will cause the process executing the remote > charge to get an ENOSPC in non-pagefault paths, and get a SIGBUS on the pagefault > path. This will be documented behavior of remote charging, and this feature is > opt-in. Users can: > - Not opt-into the feature if they want. > - Opt-into the feature and accept the risk of received ENOSPC or SIGBUS and > abort if they desire. > - Gracefully handle any resulting ENOSPC or SIGBUS errors and continue their > operation without executing the remote charge if possible. Why is ENOSPC the right error instead of ENOMEM?