Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp297768rwb; Sun, 25 Sep 2022 21:11:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4cn9aIo6fEw6sXQa87oIJqzaQm8nS3oKedRAiigmoVbit5SSyFyuDWE1nox0duogG4mcM2 X-Received: by 2002:a05:6402:1e96:b0:451:129e:1a2c with SMTP id f22-20020a0564021e9600b00451129e1a2cmr20846050edf.60.1664165507892; Sun, 25 Sep 2022 21:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664165507; cv=none; d=google.com; s=arc-20160816; b=EGRTkOhKn2y0xHYbPI0eeAViNSSX9vyGqUobMf5a2a7NwMxi+KxIf12bLOJu4sMJ0D WTdKhM8OQZfsSRrp3/gFMzkGDZdFgxxhW+rnBCWhy29wgi4xdn7CMnSaX/+f56qWjb6F DtQedy9LmYS+x+QuC1bgGRrfDNSpbh02HLzPItuUd3LOiJpeqIH8FXwsEFfBhTY4hpfD MCEZddrn0HZmSEaRna0xbah2WHamDmg49xmVAI0iw3c9MoxO4DxnMRPXx0J8TNLF79vb s3nvp+jxmEHaVz30NymdFn2RAHm5Jh31FLwdgBCYcf58j2fS+Ei+uL49qP+DlksXnFJS Oxow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=6Kb4i0mm6v9pZwbBNK1La/6ffxmbjpXjTkCflKZS3Mw=; b=KA3BMmMGe+EN4FrDQpIVHH8baaWLO6kUdsgwpqYDnNbc0eixtl51yaD2smPE8r2HGT 7ByKvLc3DRCYdnrLpbY9BBtOt5oY/lVUaKdElx5q61y0dXUQwJ3CYx1b4lGZ7svFYvDn Fm44C2MC9F1ECYOQ/BluDiTIL7Hz8TFKf/+eLpmsUvAKDxlTon9I3Tkq85/K0/cgAYBN kQREcMt2waNqfh8LdQKXCeav4K2bMn8mBLt+mVJ3c9i9/46UmmVKx0LfwlmJTeBor0i0 PWYYjSK4e5f9k0tqOkP0xHrNtUB84XAh0p0rpp4OeEfvq3e7JDnqQv+oNG5IgkLQCdCJ hpWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="M7KqJY/7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a056402280700b00448ab5d3ba3si17102188ede.1.2022.09.25.21.11.21; Sun, 25 Sep 2022 21:11:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="M7KqJY/7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232677AbiIZDiV (ORCPT + 99 others); Sun, 25 Sep 2022 23:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbiIZDiS (ORCPT ); Sun, 25 Sep 2022 23:38:18 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBE62612D for ; Sun, 25 Sep 2022 20:38:17 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id v1so5040382plo.9 for ; Sun, 25 Sep 2022 20:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date; bh=6Kb4i0mm6v9pZwbBNK1La/6ffxmbjpXjTkCflKZS3Mw=; b=M7KqJY/7x2gd1PCsMuoLwDKeICBqKrtnRWM2bztZmkzd/A+6MHl1gbKPWdDuJbBakh PObbN+N9EUBGqIsKWMx5ikDS+Lg/xwj5vIkhB+Ekifcxg5SwEyOECa5ZhL2uiNwOLRci I1z2OHsX/u7lOEzhLt3eP6aJGMfsOzEGSYm816K66IK3mR5+12u6qLR1NROPV3tEPvH2 l2t3XatAqMc58mSloeRlA1DCry7YZhVa27mKiNC9holgSmDdk3FmwjTTuwYhwiF+/Rai rgsPtkZSy0uc70R9npGAOlByKBHXm3mbYJOD1ieitPokI7+2RpmYhYIsBt/KxG5Xb+Zz 9HMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=6Kb4i0mm6v9pZwbBNK1La/6ffxmbjpXjTkCflKZS3Mw=; b=Mff7wvkHQWkSovCHozTtsZ6fO5/r+BlwtDoYHuNrpfvXOPfPvD5e71/LW6gsj+Lh0K l/+FMqPgYLUo2AL5LY8ajbPDFDvhRv7jFL9PfSUCfo/ttEWGv4JrxWBmk/p2JTbXrfyA 6ehiS9yRY+IHh4tRctuh0fjznbTyfsdtqCP5gmwoE/fcZ/tXQKvvcG2tXYusXc4HbOAH k8rkics7DqozQ4TZJseJ3+CuIqKIYTf4LaWkWhLvMq1iJo+24xiaYRsHd40UIT5uthqw +i/bTxotedS/EQets2rDTbzvOQ9sNUiz55bgXXrhgIwBZbf4UaltiJjRgI7ErGp/th0y X0GA== X-Gm-Message-State: ACrzQf19V1VDAOuOqgN6h9HmnpjxAJIGFxhYFHu7fXzgMhxxf+wcYoKf dU84Xx0TMJHt999rcS0BK8UPbA== X-Received: by 2002:a17:90b:4f8d:b0:202:dd39:c03a with SMTP id qe13-20020a17090b4f8d00b00202dd39c03amr35063928pjb.71.1664163496691; Sun, 25 Sep 2022 20:38:16 -0700 (PDT) Received: from [10.76.43.192] ([61.120.150.75]) by smtp.gmail.com with ESMTPSA id u7-20020a17090341c700b0015e8d4eb219sm10185058ple.99.2022.09.25.20.38.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Sep 2022 20:38:16 -0700 (PDT) Message-ID: Date: Mon, 26 Sep 2022 11:38:10 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 From: Gang Li Subject: Re: Re: [RFC PATCH v1] mm: oom: introduce cpuset oom To: David Rientjes Cc: Zefan Li , Tejun Heo , Johannes Weiner , Andrew Morton , Michal Hocko , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20220921064710.89663-1-ligang.bdlg@bytedance.com> <18621b07-256b-7da1-885a-c96dfc8244b6@google.com> Content-Language: en-US In-Reply-To: <18621b07-256b-7da1-885a-c96dfc8244b6@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/9/23 03:18, David Rientjes wrote: > On Wed, 21 Sep 2022, Gang Li wrote: > >> cpuset confine processes to processor and memory node subsets. >> When a process in cpuset triggers oom, it may kill a completely >> irrelevant process on another numa node, which will not release any >> memory for this cpuset. >> >> It seems that `CONSTRAINT_CPUSET` is not really doing much these >> days. Using CONSTRAINT_CPUSET, we can easily achieve node aware oom >> killing by selecting victim from the cpuset which triggers oom. >> >> Suggested-by: Michal Hocko >> Signed-off-by: Gang Li > > Hmm, is this the right approach? > > If a cpuset results in a oom condition, is there a reason why we'd need to > find a process from within that cpuset to kill? I think the idea is to > free memory on the oom set of nodes (cpuset.mems) and that can happen by > killing a process that is not a member of this cpuset. > Hi, My last patch implemented this idea[1][2]. But it needs to inc/dec a per mm_struct counter on every page allocation/release/migration. As the Unixbench show, this takes 0%-3% performance loss on different workloads[2]. So Michal Hocko inspired me to use cpuset[3]. [1]. https://lore.kernel.org/all/20220512044634.63586-1-ligang.bdlg@bytedance.com/ [2]. https://lore.kernel.org/all/20220708082129.80115-1-ligang.bdlg@bytedance.com/ [3]. https://lore.kernel.org/all/YoJ%2FioXwGTdCywUE@dhcp22.suse.cz/ > I understand the challenges of creating a NUMA aware oom killer to target > memory that is actually resident on an oom node, but this approach doesn't > seem right and could actually lead to pathological cases where a small > process trying to fork in an otherwise empty cpuset is repeatedly oom > killing when we'd actually prefer to kill a single large process. > I think there are three ways to achieve NUMA aware oom killer: 1. Count every page operations, which cause performance loss[2]. 2. Iterate over pages(like show_numa_map) for all processes, which may stuck oom. 3. Select victim in a cpuset, which may leads to pathological kill.(this patch) None of them are perfect and I'm getting stuck, do you have any ideas?