From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751539AbdE3N4u (ORCPT ); Tue, 30 May 2017 09:56:50 -0400 Received: from mail.skyhub.de ([5.9.137.197]:33498 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbdE3N4t (ORCPT ); Tue, 30 May 2017 09:56:49 -0400 Date: Tue, 30 May 2017 15:56:33 +0200 From: Borislav Petkov To: "Ghannam, Yazen" Cc: "linux-edac@vger.kernel.org" , Tony Luck , "x86@kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 2/3] x86/mce/AMD: Define a list_head for threshold blocks outside the list Message-ID: <20170530135633.y2hbkpc2ak3zkgtw@pd.tnic> References: <1495658507-7413-1-git-send-email-Yazen.Ghannam@amd.com> <1495658507-7413-2-git-send-email-Yazen.Ghannam@amd.com> <20170528172209.vgoux4bznrapiikl@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 30, 2017 at 12:39:03PM +0000, Ghannam, Yazen wrote: > Like I said in the commit message, the list_head needs to be outside the > list to access all the elements using list_for_each*. Otherwise, we won't > get a reference to the "head" element since we iterate starting from > head->next and break when !head. I believe the whole hierarchy here is done a bit differently: the list starts at threshold_bank->blocks which points to the first threshold block. So when iterating, you need to look at threshold_bank->blocks first, which is the first element and then traverse the list. This is basically how the list gets built: allocate_threshold_blocks: ... if (per_cpu(threshold_banks, cpu)[bank]->blocks) list_add(&b->miscj, &per_cpu(threshold_banks, cpu)[bank]->blocks->miscj); else per_cpu(threshold_banks, cpu)[bank]->blocks = b; per_cpu(threshold_banks, cpu)[bank]->blocks is the first element as it points to a struct threshold_block and then the ..->blocks->miscj contains any further threshold blocks present on this bank and we queue them there if ->blocks is not NULL. HTH. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.