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 BA791C433EF for ; Sat, 20 Nov 2021 05:32:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 352056B0071; Sat, 20 Nov 2021 00:31:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 301DE6B0072; Sat, 20 Nov 2021 00:31:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A2846B0073; Sat, 20 Nov 2021 00:31:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 08A7D6B0071 for ; Sat, 20 Nov 2021 00:31:57 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BF5A01852336D for ; Sat, 20 Nov 2021 05:31:46 +0000 (UTC) X-FDA: 78828186696.01.CEA86E9 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by imf29.hostedemail.com (Postfix) with ESMTP id A48459000678 for ; Sat, 20 Nov 2021 05:31:44 +0000 (UTC) Received: by mail-io1-f43.google.com with SMTP id k21so15529559ioh.4 for ; Fri, 19 Nov 2021 21:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vnmw4S1Oo24l/mBbjqvIPUjrCN4SWt+nkM7iPySscsw=; b=Is6GD84hBb9QY3j8VzxArUzIWg27YUxT7W2u8JsLG3BXkUJFEhtGH+/3LaqHJ5lj/u JzOdhu6c+qD1Xp46nfqUBMqM5YcXolH3Cm0gWBAhTvrL0U9Sok39SsnwM/M2fwM+giyC b2mttp9GnYCE5IXirYkv7ApZasb6lnRTh/4SvBkwmuuRhjox12DYv/wiXsJzFyxaUtGk uFkheaWF/Y6auNhbt4lN5qsa4bH56/C5qdfXXV9rqxo89VHFtgoxWLBWBqz2HwwYGX43 ZM+LFt1omvXDOHm9TfIFtQhEIiZpdGzRiDJ/sbcSz0UqKLsNZpP+biDAuPXg8bW6HMzh 5O2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vnmw4S1Oo24l/mBbjqvIPUjrCN4SWt+nkM7iPySscsw=; b=pDkxPXmoVCCKZ9ODcJ9p9nMz7tQdfZzJ4pgLMeeYNb7yl/l/M7uktGJZciVd7Q2a7Z 41fsxFn+QJ2oX7IG8H0seH0Bn9DkF8lWsZNN+pGkAqBiYZA+kLc34EorlV9Uqo73MaMW Pdfm1bRAzL8W1t9STv+t47fObu1iTmPEHa4ZtvWJa2nk/9abw1rZDP891U5nRCwUjLzE wx7vgVuef6naT4gIqVhbNZEk8ZQiur2tdSYd/3EXIrfYvX/8Wi5/MjX7DdBMu2eH2DwY E+mmgscoFS5lGkEDy91GSHz8b+HzoLwOY/vumE8kZ2XB3NuB9aPQYGqdwCHR93dUGLVa z+xg== X-Gm-Message-State: AOAM530Vaaw2GUZWD1XDSrsWjHDTGr7cXGSeOMOhTnAcG2ZEHyxnTR0M h3ULSy5qgBfj7cRvM53mfX3mhtdpu4pV2Id8X/NCAQ== X-Google-Smtp-Source: ABdhPJxBhvbOju0exRZ4gxIwv3a9pAvTn8srl8n5iLbXQAIxlrh8tvJvvtpWyzDjocNGmv1/aE1w6IUOj7TJiV6KpFE= X-Received: by 2002:a05:6638:4183:: with SMTP id az3mr33251237jab.56.1637386305661; Fri, 19 Nov 2021 21:31:45 -0800 (PST) MIME-Version: 1.0 References: <20211120045011.3074840-1-almasrymina@google.com> <20211120045011.3074840-3-almasrymina@google.com> In-Reply-To: From: Mina Almasry Date: Fri, 19 Nov 2021 21:31:34 -0800 Message-ID: Subject: Re: [PATCH v4 2/4] mm/oom: handle remote ooms To: Matthew Wilcox Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Jonathan Corbet , Alexander Viro , 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, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: ppgyxxeafa46nz35ah3fud8ybhheif6k Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Is6GD84h; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of almasrymina@google.com designates 209.85.166.43 as permitted sender) smtp.mailfrom=almasrymina@google.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A48459000678 X-HE-Tag: 1637386304-511881 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 9:07 PM Matthew Wilcox wrote: > > On Fri, Nov 19, 2021 at 08:50:08PM -0800, Mina Almasry wrote: > > On remote ooms (OOMs due to remote charging), the oom-killer will attempt > > to find a task to kill in the memcg under oom. The oom-killer may be > > unable to find a process to kill if there are no killable processes in > > the remote memcg. In this case, the oom-killer (out_of_memory()) will return > > false, and depending on the gfp, that will generally get bubbled up to > > mem_cgroup_charge_mapping() as an ENOMEM. > > Why doesn't it try to run the shrinkers to get back some page cache / > slab cache memory from this memcg? I understand it might not be able > to (eg if the memory is mlocked), but surely that's rare. > Please correct me if I'm wrong, but AFAICT I haven't disabled any shrinkers from running or disabled any reclaim mechanism on remote charges. What I see in the code is that when the remote memcg runs out of memory is that try_to_free_mem_cgroup_pages() gets called as normal and we do the MAX_RECLAIM_RETRIES as normal. It's only in the (rare as you point out) case where the kernel is completely unable to find memory in the remote memcg that we need to do the special handling that's described in this patch. Although this situation is probably quite rare in real-world scenarios, it's easily reproducible (and the attached test in the series does so), so my feeling is that it needs some sane handling, which I'm attempting to do in this patch.