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.0 required=3.0 tests=BAYES_00,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 E7413C433E6 for ; Tue, 14 Jul 2020 13:34:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B300F224B1 for ; Tue, 14 Jul 2020 13:34:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B300F224B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5E5868D0002; Tue, 14 Jul 2020 09:34:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 597026B0007; Tue, 14 Jul 2020 09:34:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AA4F8D0002; Tue, 14 Jul 2020 09:34:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 351186B0006 for ; Tue, 14 Jul 2020 09:34:57 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EB0AC181AC9BF for ; Tue, 14 Jul 2020 13:34:56 +0000 (UTC) X-FDA: 77036776992.25.leg91_001711626ef1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id B30FB1804E3A8 for ; Tue, 14 Jul 2020 13:34:56 +0000 (UTC) X-HE-Tag: leg91_001711626ef1 X-Filterd-Recvd-Size: 4090 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jul 2020 13:34:56 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id z13so21632057wrw.5 for ; Tue, 14 Jul 2020 06:34:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8CjL1rJJNNzSDnavAy4jf7FPmI+4yvsM7IHCyBE9QWs=; b=seaURUR46MBhlJxFgeEP9DCtq1whhQyhRQVVc0iKwNf6Bu0VexZXX5SwDx1x5TKl4x 7i0FJjgzA9tGkCkCPDtUnVmtUPwlY6oRfzc/FHdpuO4NJdHsflV0eMP8Y9mKbKe23Ziz ZrMVuGvheDgSFg6zutiQGTVINGyKS9weIGxcrJOKqdGtDbfRc5ByurQPqEH4lHUX2VSa 7D7C1DaMl6ILWvjZVDCxu1qTzdSCWa4eaxrQbla/8lAxkRJIEGbWlyoXjlWxMWCJ3D/2 8ZPeUunNR1SnYlfR4RL+8et/ArXilzxGxFZd399U0jEs/pwwRMellQKUnv1SNGPtoCsY H7Wg== X-Gm-Message-State: AOAM533tMdzMM+z/7IgmXg4riuFyuJeUkgD7vg3sELebGq1wDZ5Qa5Cm 4bv5virTXozAV24C+w+FOiQ= X-Google-Smtp-Source: ABdhPJwnh6Va5sBHoCuIT/yedw7aaTqSTPfb4Fbc71E0uuOD2X0KBlBHMwxn5HoseDeOuAslK87AFQ== X-Received: by 2002:adf:82e1:: with SMTP id 88mr5353142wrc.376.1594733695034; Tue, 14 Jul 2020 06:34:55 -0700 (PDT) Received: from localhost (ip-37-188-148-171.eurotel.cz. [37.188.148.171]) by smtp.gmail.com with ESMTPSA id f197sm4826364wme.33.2020.07.14.06.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 06:34:54 -0700 (PDT) Date: Tue, 14 Jul 2020 15:34:53 +0200 From: Michal Hocko To: Yafang Shao Cc: Tetsuo Handa , David Rientjes , Andrew Morton , Linux MM Subject: Re: [PATCH] mm, oom: check memcg margin for parallel oom Message-ID: <20200714133453.GM24642@dhcp22.suse.cz> References: <1594728512-18969-1-git-send-email-laoar.shao@gmail.com> <20200714123726.GI24642@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: B30FB1804E3A8 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 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). -- Michal Hocko SUSE Labs