Received: by 10.213.65.68 with SMTP id h4csp1232420imn; Wed, 14 Mar 2018 13:42:45 -0700 (PDT) X-Google-Smtp-Source: AG47ELsFBOYn2gig9f3UyEi5BfcNUspWek2Oi3DaszHUybmENcpoD5mxCrBurDXmQ6Xgtyb1yY1T X-Received: by 10.98.207.68 with SMTP id b65mr3344181pfg.151.1521060165658; Wed, 14 Mar 2018 13:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521060165; cv=none; d=google.com; s=arc-20160816; b=WJZWX4mDXreTjDNB7hXLPpewq8MeOphxyRKSlQr32zEBxj4GxZ3OyKV9HC9ymn22Jh 5F5j4omQy+eOmxUUJE96kAR5HXitiVYbe4jNEkb40gNC9keovYjdvFoegJn2JqEnmbJz Jhtw7/Ra9C9dXPMshTRN6dxXUJ50W04KE0Mt64uTgVMa0hvseQ8CkoqCsC7qkGpSDAwS mA7eI3GU1dFJgszs0dTF2tp2jeOjcIl862beu+McjtOBQyXZQpoRRtLS9OgbL+LTFgnK NBG8o9i0WZf51UiCmvh91Q1Kw5zPzpq5KUSORzUZ3eoHtIvdqmom/YCyxVMM6YfbfX2o t2kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=4Bte+yvrl469JjN9uXL9KYzrPwpe6yF/b78Yqf2mWtM=; b=SqTZWXjXOoAj0dQpUwgrwDGX5zjJQxpRLKasx75qoVYpCwFkZGnG4OTpyHjghAwIeg /XoGpsYhFvtpr7wfXDiI7Wpb53uHP3vqH/LJk0qcwAjIluz5/eFZNRmDoiwJ6jFXiyZz ZaOprDtxVWdEhihm2t45783mLtn9xSU+ssY3ENZYj45//FBI0KkgmWbN/NAz3tZvyEGS wLVtcjKVcrc+qv441JIR/4ekziJplFS9vFE2TIzcl6d0/woQPNT7eEu1h149s0IIGv9o X57ovD/diw57TJ28vwGTrBL61Gsr9lXj6bOqTu0XXEnX+6bG9s2+XvIHJRQ6Vc7GEX82 MPAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DarlMN+k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f125si2303164pgc.736.2018.03.14.13.42.31; Wed, 14 Mar 2018 13:42:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DarlMN+k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbeCNUlH (ORCPT + 99 others); Wed, 14 Mar 2018 16:41:07 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38135 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751289AbeCNUlF (ORCPT ); Wed, 14 Mar 2018 16:41:05 -0400 Received: by mail-pg0-f67.google.com with SMTP id a15so1885224pgn.5 for ; Wed, 14 Mar 2018 13:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=4Bte+yvrl469JjN9uXL9KYzrPwpe6yF/b78Yqf2mWtM=; b=DarlMN+kQmTJoiOP5EVd3IUKkCJ2Qw08hkHP/jU1pg58CQMqfVmCnSsJFBMVe+2sRQ G0JFlIAB5bAnycPJNKh6p1djYTpI0NIDFpxQOZu3zvG/Hhd0ZM8njCgqnA1kaQUcXH5q xE5V2BGSgG3ad/3+KR92YUnzmUOiJRYNdOz5rXPoH/gKFKqLdDGIBsAgk0qwr1/nWrGq iU48iJA6qrreYU71CTcMMNMj/0rjELZ05QIqwggAMoIprXlN7PGngdAQjLrBZYuXOazO EX+EdxvKI1GpnhxLNQEgSUZ9UVx2QrjSdB5/4hxGoJ/YyuRlloFUTlZweOJW2T3NUgLF Gmtw== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=4Bte+yvrl469JjN9uXL9KYzrPwpe6yF/b78Yqf2mWtM=; b=Kz8VODaLSowg2EIVRj6O957AhUU3OwykiNC2ByPH+tKmJU6K7AUbWyHSMP68IauWjk RR1gmQ6cnQtBNTS60aDmrnbaKl1K3n7wJc9pxtMwfNNhv3hdgL/7htPLdLQcRNH38Po1 zqgG4tgAGr8zm5/ey+OFc3ye1YXedGjQvDcBrSyuvvHHacs+H4JNFqVymIVawVjmW5/Y MK89IIimTTC6p5UVVjsUPdX0YA4D743uebiupMefCSGz0MZG5wROlPeoTvTyKNRNKp4E BLZ9/HNIzBTHP+hr51Zj1NyNNKtojCTHSg5QNwEPbAyBl80dZnmIjjwkp7vQ+viptkgb G51g== X-Gm-Message-State: AElRT7EbO8hY5CrdqzdWKr9aaRJLJjqF24TNe6oK00i7oaGDTRHAp9zO VTndCh7VmJCusjlXOdpW6xB7ug== X-Received: by 10.98.9.5 with SMTP id e5mr5544370pfd.189.1521060064513; Wed, 14 Mar 2018 13:41:04 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id d12sm6527298pfn.42.2018.03.14.13.41.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 13:41:03 -0700 (PDT) Date: Wed, 14 Mar 2018 13:41:03 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Roman Gushchin cc: Andrew Morton , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tejun Heo , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch -mm] mm, memcg: evaluate root and leaf memcgs fairly on oom In-Reply-To: <20180314121700.GA20850@castle.DHCP.thefacebook.com> Message-ID: References: <20180314121700.GA20850@castle.DHCP.thefacebook.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Mar 2018, Roman Gushchin wrote: > > @@ -2618,92 +2620,65 @@ static long memcg_oom_badness(struct mem_cgroup *memcg, > > if (nodemask && !node_isset(nid, *nodemask)) > > continue; > > > > - points += mem_cgroup_node_nr_lru_pages(memcg, nid, > > - LRU_ALL_ANON | BIT(LRU_UNEVICTABLE)); > > - > > pgdat = NODE_DATA(nid); > > - points += lruvec_page_state(mem_cgroup_lruvec(pgdat, memcg), > > - NR_SLAB_UNRECLAIMABLE); > > + if (is_root_memcg) { > > + points += node_page_state(pgdat, NR_ACTIVE_ANON) + > > + node_page_state(pgdat, NR_INACTIVE_ANON); > > + points += node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE); > > + } else { > > + points += mem_cgroup_node_nr_lru_pages(memcg, nid, > > + LRU_ALL_ANON); > > + points += lruvec_page_state(mem_cgroup_lruvec(pgdat, memcg), > > + NR_SLAB_UNRECLAIMABLE); > > + } > > } > > > > - points += memcg_page_state(memcg, MEMCG_KERNEL_STACK_KB) / > > - (PAGE_SIZE / 1024); > > - points += memcg_page_state(memcg, MEMCG_SOCK); > > - points += memcg_page_state(memcg, MEMCG_SWAP); > > - > > + if (is_root_memcg) { > > + points += global_zone_page_state(NR_KERNEL_STACK_KB) / > > + (PAGE_SIZE / 1024); > > + points += atomic_long_read(&total_sock_pages); > ^^^^^^^^^^^^^^^^ > BTW, where do we change this counter? > Seems like it was dropped from the patch somehow. It is intended to do atomic_long_add(nr_pages) in mem_cgroup_charge_skmem() and atomic_long_add(-nr_pages) mem_cgroup_uncharge_skmem(). > I also doubt that global atomic variable can work here, > we probably need something better scaling. > Why do you think an atomic_long_add() is too expensive when we're already disabling irqs and dong try_charge()?