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 0DB7EC433E4 for ; Tue, 14 Jul 2020 13:40:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C0F5E224B2 for ; Tue, 14 Jul 2020 13:40:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lL88NK4H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0F5E224B2 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 4F7E86B0006; Tue, 14 Jul 2020 09:40:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 459EA6B0007; Tue, 14 Jul 2020 09:40:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 321F56B0008; Tue, 14 Jul 2020 09:40:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 1CBC56B0006 for ; Tue, 14 Jul 2020 09:40:45 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 935C62DFA for ; Tue, 14 Jul 2020 13:40:44 +0000 (UTC) X-FDA: 77036791608.22.badge16_2215ccb26ef1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 2377918038E6A for ; Tue, 14 Jul 2020 13:40:43 +0000 (UTC) X-HE-Tag: badge16_2215ccb26ef1 X-Filterd-Recvd-Size: 4606 Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jul 2020 13:40:42 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id k23so17251677iom.10 for ; Tue, 14 Jul 2020 06:40:42 -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=HwOEP+N+/gjfdyYpZQkepyyZku+GNAJ2LrgiJa5TGuo=; b=lL88NK4HTGoSlL06jrjHqpc2huyiqd1tGYc0pole1oDWk/CjMNyGFMjGdO6LgchKWr 1o2cOvsgqcO6DqKAKWUpYANtw6ew7h7vJKiAKjX7OEUKXNiLUJD7CPy9juyFwLLumhOI o9eekf6lTCHQuhNHPDT4y2ArkxWD5yj3sBDxbJKh0fUPj5e/s0yTsG2yWvqFSS88qjUL /61c6f/Onzzgxh4z96MUE347KzJHNR2AIRdS7bjguDVkj7V54BQXgXI/M9D6Uq05TDHs bhLF44gjKvKPl+N3tUwYTJPbQwz8A0i83QYsY6nXi8PpXWZ5Uf1sRMQ+voak6OdmxR1E HTYw== 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=HwOEP+N+/gjfdyYpZQkepyyZku+GNAJ2LrgiJa5TGuo=; b=oU/nT6caesOg44G5kddJ3VEIlD03Al7Az5Dj6hgT3Sa/5HU+hTtBUDoSCmaxqXr6gN W83PggIViDh3hM7XMsNsX/nB1gKZ03SaAtgI7AXOmUAuxJS641qjwk3gKCGdGDk+bmBh /9Q9ozH7o1NOrdKBqTQ4HFJhGzQU/ebTq/X4/vIggW4gfu/q9SGvKQHmU1wPyw92Dhfx qYC3i/WNw3kRzJB5vLChtOIcROovGBxy9vQVSewBgFcJaMbmT1HRew7u4wv4Ejqg5JaE 84RKDNLcJ5cGzeV+kcGoapqYSNrPB9jMr2SLnaKktHyUzmfjYqLhw2P5fJZHfSm0mRq8 ilNQ== X-Gm-Message-State: AOAM532FGxeysEzXAn9Q1Hlu4Qa+S8yDwvFVh468hhtnozvecAJ6+uol 75JivKbXed9Lj/P5/ufDx3xL2rBFAzVZk4q8o+s= X-Google-Smtp-Source: ABdhPJyhX4gF1BU5zj4KKGQRosKJx8RIOVil5femAVv0UWAAU4ywVeF3xEk4uXRTM+kCkoO1R4FsWytGFOV4VAe4ayI= X-Received: by 2002:a05:6602:6c4:: with SMTP id n4mr4969960iox.202.1594734042093; Tue, 14 Jul 2020 06:40:42 -0700 (PDT) MIME-Version: 1.0 References: <1594728512-18969-1-git-send-email-laoar.shao@gmail.com> <20200714123726.GI24642@dhcp22.suse.cz> <20200714133453.GM24642@dhcp22.suse.cz> In-Reply-To: <20200714133453.GM24642@dhcp22.suse.cz> From: Yafang Shao Date: Tue, 14 Jul 2020 21:40:06 +0800 Message-ID: Subject: Re: [PATCH] mm, oom: check memcg margin for parallel oom To: Michal Hocko Cc: Tetsuo Handa , David Rientjes , Andrew Morton , Linux MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 2377918038E6A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Tue, Jul 14, 2020 at 9:34 PM Michal Hocko wrote: > > On Tue 14-07-20 21:25:04, Yafang Shao wrote: > > On Tue, Jul 14, 2020 at 8:37 PM Michal Hocko wrote: > [...] > > > > @@ -1560,16 +1560,31 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, > > > > .gfp_mask = gfp_mask, > > > > .order = order, > > > > }; > > > > - bool ret; > > > > + bool ret = true; > > > > > > > > if (mutex_lock_killable(&oom_lock)) > > > > return true; > > > > + > > > > /* > > > > * A few threads which were not waiting at mutex_lock_killable() can > > > > * fail to bail out. Therefore, check again after holding oom_lock. > > > > */ > > > > - ret = should_force_charge() || out_of_memory(&oc); > > > > + if (should_force_charge()) > > > > + goto out; > > > > + > > > > + /* > > > > + * Different tasks may be doing parallel oom, so after hold the > > > > + * oom_lock the task should check the memcg margin again to check > > > > + * whether other task has already made progress. > > > > + */ > > > > + if (mem_cgroup_margin(memcg) >= (1 << order)) > > > > + goto out; > > > > > > Is there any reason why you simply haven't done this? (+ your comment > > > which is helpful). > > > > > > > No strong reason. > > I just think that threads of a multi-thread task are more likely to do > > parallel OOM, so I checked it first. > > I can change it as you suggested below, as it is more simple. > > I would rather go with simplicity. This is a super slow path so ordering > of checks shouldn't matter much (if at all). > Sure. -- Thanks Yafang