Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754295AbcJEBVk (ORCPT ); Tue, 4 Oct 2016 21:21:40 -0400 Received: from mail-oi0-f45.google.com ([209.85.218.45]:36336 "EHLO mail-oi0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbcJEBVi (ORCPT ); Tue, 4 Oct 2016 21:21:38 -0400 MIME-Version: 1.0 In-Reply-To: <20161004093216.GA21170@cmpxchg.org> References: <20161004093216.GA21170@cmpxchg.org> From: Linus Torvalds Date: Tue, 4 Oct 2016 18:21:37 -0700 X-Google-Sender-Auth: 9M_nXPBiH9myRCLAzuVfr09_MbY Message-ID: Subject: Re: BUG_ON() in workingset_node_shadows_dec() triggers To: Johannes Weiner Cc: Andrew Morton , Antonio SJ Musumeci , Miklos Szeredi , Linux Kernel Mailing List , stable Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1718 Lines: 39 On Tue, Oct 4, 2016 at 2:32 AM, Johannes Weiner wrote: > > In the workingset code, if we detect radix tree nodes in a state in > which they shouldn't be on the shadow node LRU, we could simply warn, > abort the reclaim process and leave them off the LRU. Something like > the below patch. I don't hate that patch, but I wonder why the counts get corrupted and the workingset_node_shadows_dec() thing triggered in the first place. So I do think that the BUG_ON()'s there in shadow_lru_isolate() should be removed, but since they haven't triggered I worry more abut the one that has. I've tried to follow the counting, and I don't see any obvious bugs in the counting per se. I went as far as look where we even initialize node->count. Btw, whoever wrote that code liked the whole SLAB desctructor model a lot too much. Initializing the fields as you free something is rather silly from a cache use standpoint. You're just touching cachelines that are almost guaranteed to be wasted. Why isn't that init code just done at allocation time instead of in that radix_tree_node_rcu_free() destructor? But I couldn't see anything actively *buggy*, even if I think the code is oddly structured. So to debug that, I'd actually like to see something that adds a few more warnings to try to catch *where* the count goes bad For example, is it actually valid to free a radix_tree_node that has a non-zero count? Shouldn't all the shadow entries have been removed? The problem with the BUG_ON() at workingset_node_shadows_dec() time isn't just that it killed the machine, it also doesn't actually give very much information. The count has presumably been mis-done long before.. Linus