From: Yazen Ghannam <Yazen.Ghannam@amd.com>
To: <linux-edac@vger.kernel.org>
Cc: Borislav Petkov <bp@suse.de>, Tony Luck <tony.luck@intel.com>,
<x86@kernel.org>, <linux-kernel@vger.kernel.org>,
Yazen Ghannam <yazen.ghannam@amd.com>
Subject: [PATCH 2/3] x86/mce/AMD: Define a list_head for threshold blocks outside the list
Date: Wed, 24 May 2017 15:41:46 -0500 [thread overview]
Message-ID: <1495658507-7413-2-git-send-email-Yazen.Ghannam@amd.com> (raw)
In-Reply-To: <1495658507-7413-1-git-send-email-Yazen.Ghannam@amd.com>
From: Yazen Ghannam <yazen.ghannam@amd.com>
There needs to be a list_head outside of a linked list in order to iterate
over it and have access to all its elements. This is because the
list_for_each* macros iterate starting from head->next rather than head.
Define a list_head for the threshold blocks list in struct threshold_bank
since this is the container of the list. Use this list_head as the head
instead of the first element in the blocks list.
This is needed in a future patch where we read the blocks list in the
threshold interrupt handler. Currently, we'll always skip block 0 since it
is the head of the list.
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
arch/x86/include/asm/amd_nb.h | 2 ++
arch/x86/kernel/cpu/mcheck/mce_amd.c | 19 ++++++++++---------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
index da181ad..81334b4 100644
--- a/arch/x86/include/asm/amd_nb.h
+++ b/arch/x86/include/asm/amd_nb.h
@@ -55,6 +55,8 @@ struct threshold_bank {
struct kobject *kobj;
struct threshold_block *blocks;
+ struct list_head blocks_head;
+
/* initialized to the number of CPUs on the node sharing this bank */
refcount_t cpus;
};
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index d11f94e..2074b870 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -1119,15 +1119,15 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,
threshold_ktype.default_attrs[2] = NULL;
}
- INIT_LIST_HEAD(&b->miscj);
-
- if (per_cpu(threshold_banks, cpu)[bank]->blocks) {
- list_add(&b->miscj,
- &per_cpu(threshold_banks, cpu)[bank]->blocks->miscj);
- } else {
+ if (!per_cpu(threshold_banks, cpu)[bank]->blocks) {
+ INIT_LIST_HEAD(&per_cpu(threshold_banks, cpu)[bank]->blocks_head);
per_cpu(threshold_banks, cpu)[bank]->blocks = b;
}
+ INIT_LIST_HEAD(&b->miscj);
+
+ list_add(&b->miscj, &per_cpu(threshold_banks, cpu)[bank]->blocks_head);
+
err = kobject_init_and_add(&b->kobj, &threshold_ktype,
per_cpu(threshold_banks, cpu)[bank]->kobj,
get_name(bank, b));
@@ -1158,7 +1158,7 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,
static int __threshold_add_blocks(struct threshold_bank *b)
{
- struct list_head *head = &b->blocks->miscj;
+ struct list_head *head = &b->blocks_head;
struct threshold_block *pos = NULL;
struct threshold_block *tmp = NULL;
int err = 0;
@@ -1256,7 +1256,7 @@ static void deallocate_threshold_block(unsigned int cpu,
if (!head)
return;
- list_for_each_entry_safe(pos, tmp, &head->blocks->miscj, miscj) {
+ list_for_each_entry_safe(pos, tmp, &head->blocks_head, miscj) {
kobject_put(&pos->kobj);
list_del(&pos->miscj);
kfree(pos);
@@ -1273,7 +1273,7 @@ static void __threshold_remove_blocks(struct threshold_bank *b)
kobject_del(b->kobj);
- list_for_each_entry_safe(pos, tmp, &b->blocks->miscj, miscj)
+ list_for_each_entry_safe(pos, tmp, &b->blocks_head, miscj)
kobject_del(&pos->kobj);
}
@@ -1307,6 +1307,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
deallocate_threshold_block(cpu, bank);
free_out:
+ list_del(&b->blocks_head);
kobject_del(b->kobj);
kobject_put(b->kobj);
kfree(b);
--
2.7.4
next prev parent reply other threads:[~2017-05-24 20:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 20:41 [PATCH 1/3] x86/mce/AMD: Use msr_stat when clearing MCA_STATUS Yazen Ghannam
2017-05-24 20:41 ` Yazen Ghannam [this message]
2017-05-28 17:22 ` [PATCH 2/3] x86/mce/AMD: Define a list_head for threshold blocks outside the list Borislav Petkov
2017-05-30 12:39 ` Ghannam, Yazen
2017-05-30 13:56 ` Borislav Petkov
2017-05-30 14:06 ` Ghannam, Yazen
2017-05-30 14:10 ` Borislav Petkov
2017-05-24 20:41 ` [PATCH 3/3] x86/mce/AMD: Use saved threshold block info in interrupt handler Yazen Ghannam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1495658507-7413-2-git-send-email-Yazen.Ghannam@amd.com \
--to=yazen.ghannam@amd.com \
--cc=bp@suse.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®