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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADEF2C433E1 for ; Wed, 15 Jul 2020 03:32:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6CD9A20672 for ; Wed, 15 Jul 2020 03:32:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M1ZsddCC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CD9A20672 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DFADA6B0005; Tue, 14 Jul 2020 23:32:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA9F46B0006; Tue, 14 Jul 2020 23:32:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C71F16B0007; Tue, 14 Jul 2020 23:32:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id AD77C6B0005 for ; Tue, 14 Jul 2020 23:32:12 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5080E1EE6 for ; Wed, 15 Jul 2020 03:32:12 +0000 (UTC) X-FDA: 77038886904.25.cry55_3d151a226ef6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 1B5B51804E3A0 for ; Wed, 15 Jul 2020 03:32:12 +0000 (UTC) X-HE-Tag: cry55_3d151a226ef6 X-Filterd-Recvd-Size: 5641 Received: from mail-il1-f196.google.com (mail-il1-f196.google.com [209.85.166.196]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jul 2020 03:32:11 +0000 (UTC) Received: by mail-il1-f196.google.com with SMTP id x9so769581ila.3 for ; Tue, 14 Jul 2020 20:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7vjSWLOZlC2MvLWJ6WfiHMxDafuhO3YkBcDhiuJqeoQ=; b=M1ZsddCCb2vPBKm8wQO/Ko1VrTB71XnT5epaZxzz9pQciOhNGIkl5IMadWa1k8ToET QqGBaMjAGpmXpJdFakjKMmi/p6rVykaT2Mq5wRpLj6kGuM5MHwIKkeqMQZ7iJJ72EZrw 9AUp1UoPMjfrDQJpgEw3EmoPIe0t8Wp9DT/LQoz+Dt8lj9wUX7ANgX5fEUhoyCv6JFjw rMws1U2QwTw79BfpnEflK0vtYcKlvEDdYOw2ANTFIcFmNRXAUKKuk+M7e2ve0jbTHnFC GOarH4fznAjuHXiLvwtyTbtsigZthh8u3qHLPeUMUjEiRS676yS6nOJkfXDKVvCNE0UI 2b3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7vjSWLOZlC2MvLWJ6WfiHMxDafuhO3YkBcDhiuJqeoQ=; b=VvGfXTPOssXkGDHZXXhMdekehkLNdyRU+RT8jk1RplDyFD1m6atZp4TkFqwkvrXRpJ QWwW8r2C7oNxTMYuYper6FV2nx+ZFQHb3Xm8COjlZlUuCEVQp7qCbHZwQ4c5EDDy7LYo tjnacdgRaAkbmrH8g0SL/Vep12QonlaPoNKo+Y7otpLeptbFDsV5aTweF8DBm8uMHkMP 7bjzNG3nqy4wf1K7SnbFk1AP64j4hzLRL2N6gUHNMueELab1rgUF0d7WVXl2ZBAk50MU UwqgrKwIRPjHDD+eioegnlwEfrZExg88n1/2Ef2pY3RvFRTWnJzkXV9e6m40D2ol2qIm FItw== X-Gm-Message-State: AOAM532emg3M61gnIml/4iX1/cFjwfHQmNM4F80mzspVrEz5ENjk4BO/ UC4H5x74+KCrpRe0fTmD+myM7aYzx7JfSEKGsgA= X-Google-Smtp-Source: ABdhPJwq799VZ8wLM8bYHGOC1WfbnyIWl4Knp38qMfw0LBcvkk6GMVQSYoGZGSsau+JqEn+NIyRHYzbULhYMrcOlXrA= X-Received: by 2002:a05:6e02:d4c:: with SMTP id h12mr8237582ilj.168.1594783931103; Tue, 14 Jul 2020 20:32:11 -0700 (PDT) MIME-Version: 1.0 References: <1594735034-19190-1-git-send-email-laoar.shao@gmail.com> In-Reply-To: From: Yafang Shao Date: Wed, 15 Jul 2020 11:31:35 +0800 Message-ID: Subject: Re: [PATCH v2] memcg, oom: check memcg margin for parallel oom To: David Rientjes Cc: Michal Hocko , Tetsuo Handa , Andrew Morton , Johannes Weiner , Linux MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 1B5B51804E3A0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Wed, Jul 15, 2020 at 11:18 AM David Rientjes wrote: > > On Wed, 15 Jul 2020, Yafang Shao wrote: > > > > It has successfully resolved it for several years in our kernel, we tried > > > an approach similiar to yours but saw many instances where memcg oom kills > > > continued to proceed even though the memcg information dumped to the > > > kernel log showed memory available. > > > > > > If this was a page or two that became available due to memory freeing, > > > it's not a significant difference. Instead, if this races with an oom > > > notification and a process exiting or being SIGKILL'd, it becomes much > > > harder to explain to a user why their process was oom killed when there > > > are tens of megabytes of memory available as shown by the kernel log (the > > > freeing/exiting happened during a particularly long iteration of processes > > > attached to the memcg, for example). > > > > > > That's what motivated a change to moving this to out_of_memory() directly, > > > we found that it prevented even more unnecessary oom kills, which is a > > > very good thing. It may only be easily observable and make a significant > > > difference at very large scale, however. > > > > > > > Thanks for the clarification. > > > > If it is the race which causes this issue and we want to reduce the > > race window, I don't know whether it is proper to check the memcg > > margin in out_of_memory() or do it before calling do_send_sig_info(). > > Because per my understanding, dump_header() always takes much more > > time than select_bad_process() especially if there're slow consoles. > > So the race might easily happen when doing dump_header() or dumping > > other information, but if we check the memcg margin after dumping this > > oom info, it would be strange to dump so much oom logs without killing > > a process. > > > > Absolutely correct :) In my proposed patch, we declare dump_header() as > the "point of no return" since we don't want to dump oom kill information > to the kernel log when nothing is actually killed. We could abort at the > very last minute, as you mention, but I think that may have an adverse > impact on anything that cares about that log message. How about storing the memcg information in oom_control when the memcg oom is triggered, and then show this information in dump_header() ? IOW, the OOM info really shows the memcg status when oom occurs, rather than the memcg status when this info is printed. -- Thanks Yafang