Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp464656yba; Thu, 9 May 2019 00:23:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcxCo9ll2GV27p8iysOb/AJQQvbcyyCTROeuF9FpOjbslbx4/FJvn79VzwM99Ov04J0LgW X-Received: by 2002:a17:902:d88b:: with SMTP id b11mr3134074plz.186.1557386625430; Thu, 09 May 2019 00:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557386625; cv=none; d=google.com; s=arc-20160816; b=DZEIKTfXN20lwMbcvxH20n9Z4ikOgQpa1cVqhI1F6Ez2G53Xfn+8xB1n3bhB1ymYRs 3lTU4j0nO3uqmwJqLeJ9S4Wapr8BJLHyJ51LJdCyOLLfQE7L3Cv/GZFUvrIWecM5wr06 GKDcRvaHfro+P6mZBPFK5qwFsl/ZGVM+uSV+3g/v7F1mrWlgdRHLVucjZsWfA2JXWbWj +GG5ION9RyO1ZY4GDmIPHwjTu1VBfosXFV97QOrGgctWl5xVkz0ON8Oq4xAFsoyOifJU G85i49Q/DcNOkSMSdIRYWxHDPaZcgRUzH5n/1Gf1qnDQa+AKJq7hp4RQG992RrwzGYd7 WUDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=A+wsiT3vu0EmiAAwgNFrbpx1FBKhfF4sMlpe8qyJugA=; b=idYyG1uRzCtHTQaiijhToqz1qa+UE/DrT8szrg+9HWJRGXm3G9/uvsi0C5nagNCfT0 x6BCm9X9Cga8KGy2bcks0l+VQ9Dn265sD3cqdLx2QqYtU8P9zu+55Evpd9+z/i4Wco7x XOP3/ggiPEwMJDClnwuo8VcvFT8guvLKuDVTkKVpFWmNrHwiWlt9wOvIqthBYWX4G94a SjnXHtrJG/XikcWfZ/Vn/wJXuYa8bwZxjC0500e7Ib22Z/HYdyIhEmmTpxDpVPyKoC7X 527/1dWOES5Qxu99Mb1j08CEtMoEBI9/bNe5x4uSFpBoe4dCPD+cph4EJAn1mZdFSWwF sdSQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20si1889235pgm.94.2019.05.09.00.23.28; Thu, 09 May 2019 00:23: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726710AbfEIHVs (ORCPT + 99 others); Thu, 9 May 2019 03:21:48 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46006 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbfEIHVs (ORCPT ); Thu, 9 May 2019 03:21:48 -0400 Received: by mail-wr1-f68.google.com with SMTP id s15so1393928wra.12; Thu, 09 May 2019 00:21:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=A+wsiT3vu0EmiAAwgNFrbpx1FBKhfF4sMlpe8qyJugA=; b=T+XM4p3GUt+2Pwql6Vmf1JjwRDtlseiFy2ejQZD0tbVuIXf16lV8p/w7nQ8EuhRL0S +7t0tp2NqRT2U8fBLUowzzoBy8QqGig/7+jUotArU+9Ve15iGxuUotm4kLa2VA+TFKJl Ja+1+KKwieInhwTUTWEg1wnqHHUL26tJ+fH4QXeU07YVRQPB9NUmkjutSYIG8jxFW70G DQuOlQQ34p3wOsYsGHLA3XAS8SnHzlVr8vamrGls9N+7xBFzvNRV9wsF572L100M3b+B /cI6tOnyr63jbbUIyWkmPXwa7J8WJnw1ef6wybZlkPA/zcaAxH4YzdPDd++OmNcTl21Y 3yiw== X-Gm-Message-State: APjAAAVmIHkkbUEEn0CVt1lop6BOwhupaseNbZyZ21v2Oc3X63qiMka3 64H+b0omcAxY2k3I7hAjg64= X-Received: by 2002:a5d:6249:: with SMTP id m9mr1590418wrv.255.1557386505152; Thu, 09 May 2019 00:21:45 -0700 (PDT) Received: from ?IPv6:2a0b:e7c0:0:107::49? ([2a0b:e7c0:0:107::49]) by smtp.gmail.com with ESMTPSA id 130sm1502350wmd.15.2019.05.09.00.21.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 00:21:43 -0700 (PDT) Subject: Re: [PATCH] memcg: make it work on sparse non-0-node systems To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Vladimir Davydov , cgroups@vger.kernel.org, Raghavendra K T References: <359d98e6-044a-7686-8522-bdd2489e9456@suse.cz> <20190429105939.11962-1-jslaby@suse.cz> From: Jiri Slaby Openpgp: preference=signencrypt Autocrypt: addr=jslaby@suse.cz; prefer-encrypt=mutual; keydata= mQINBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6Foq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Hez9YGW/RcI/WC8Y4Z/7FS ITZhASwaCOzy/vX2yC6iTx4AMFt+a6Z6uH/xGE8pG5NbGtd02r+m7SfuEDoG3Hs1iMGecPyV XxCVvSV6dwRQFc0UOZ1a6ywwCWfGOYqFnJvfSbUiCMV8bfRSWhnNQYLIuSv/nckyi8CzCYIg c21cfBvnwiSfWLZTTj1oWyj5a0PPgGOdgGoIvVjYXul3yXYeYOqbYjiC5t99JpEeIFupxIGV ciMk6t3pDrq7n7Vi/faqT+c4vnjazJi0UMfYnnAzYBa9+NkfW0w5W9Uy7kW/v7SffH/2yFiK 9HKkJqkN9xYEYaxtfl5pelF8idoxMZpTvCZY7jhnl2IemZCBMs6s338wS12Qro5WEAxV6cjD VSdmcD5l9plhKGLmgVNCTe8DPv81oDn9s0cIRLg9wNnDtj8aIiH8lBHwfUkpn32iv0uMV6Ae sLxhDWfOR4N+wu1gzXWgLel4drkCJcuYK5IL1qaZDcuGR8RPo3jbFO7Y Message-ID: <414a361f-90c5-36ef-e290-c3551595e854@suse.cz> Date: Thu, 9 May 2019 09:21:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190429105939.11962-1-jslaby@suse.cz> Content-Type: text/plain; charset=iso-8859-2 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vladimir, as you are perhaps the one most familiar with the code, could you take a look on this? On 29. 04. 19, 12:59, Jiri Slaby wrote: > We have a single node system with node 0 disabled: > Scanning NUMA topology in Northbridge 24 > Number of physical nodes 2 > Skipping disabled node 0 > Node 1 MemBase 0000000000000000 Limit 00000000fbff0000 > NODE_DATA(1) allocated [mem 0xfbfda000-0xfbfeffff] > > This causes crashes in memcg when system boots: > BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 > #PF error: [normal kernel read fault] > ... > RIP: 0010:list_lru_add+0x94/0x170 > ... > Call Trace: > d_lru_add+0x44/0x50 > dput.part.34+0xfc/0x110 > __fput+0x108/0x230 > task_work_run+0x9f/0xc0 > exit_to_usermode_loop+0xf5/0x100 > > It is reproducible as far as 4.12. I did not try older kernels. You have > to have a new enough systemd, e.g. 241 (the reason is unknown -- was not > investigated). Cannot be reproduced with systemd 234. > > The system crashes because the size of lru array is never updated in > memcg_update_all_list_lrus and the reads are past the zero-sized array, > causing dereferences of random memory. > > The root cause are list_lru_memcg_aware checks in the list_lru code. > The test in list_lru_memcg_aware is broken: it assumes node 0 is always > present, but it is not true on some systems as can be seen above. > > So fix this by checking the first online node instead of node 0. > > Signed-off-by: Jiri Slaby > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Vladimir Davydov > Cc: > Cc: > Cc: Raghavendra K T > --- > mm/list_lru.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/mm/list_lru.c b/mm/list_lru.c > index 0730bf8ff39f..7689910f1a91 100644 > --- a/mm/list_lru.c > +++ b/mm/list_lru.c > @@ -37,11 +37,7 @@ static int lru_shrinker_id(struct list_lru *lru) > > static inline bool list_lru_memcg_aware(struct list_lru *lru) > { > - /* > - * This needs node 0 to be always present, even > - * in the systems supporting sparse numa ids. > - */ > - return !!lru->node[0].memcg_lrus; > + return !!lru->node[first_online_node].memcg_lrus; > } > > static inline struct list_lru_one * > -- js suse labs