From: Borislav Petkov <bp@alien8.de>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org,
Tony Luck <tony.luck@intel.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 2/2] ras: close the race condition with timer
Date: Tue, 16 Apr 2019 11:58:52 +0200 [thread overview]
Message-ID: <20190416095852.GA31772@zn.tnic> (raw)
In-Reply-To: <20190416012001.5338-2-xiyou.wangcong@gmail.com>
On Mon, Apr 15, 2019 at 06:20:01PM -0700, Cong Wang wrote:
> cec_timer_fn() is a timer callback which reads ce_arr.array[]
> and updates its decay values. Elements could be added to or
> removed from this global array in parallel, although the array
> itself will not grow or shrink. del_lru_elem_unlocked() uses
> FULL_COUNT() as a key to find a right element to remove,
> which could be affected by the parallel timer.
>
> Fix this by converting the mutex to a spinlock and holding it
> inside the timer.
>
> Fixes: 011d82611172 ("RAS: Add a Corrected Errors Collector")
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
> drivers/ras/cec.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
> index 61332c9aab5a..a82c9d08d47a 100644
> --- a/drivers/ras/cec.c
> +++ b/drivers/ras/cec.c
> @@ -117,7 +117,7 @@ static struct ce_array {
> };
> } ce_arr;
>
> -static DEFINE_MUTEX(ce_mutex);
> +static DEFINE_SPINLOCK(ce_lock);
Nah, pls keep the simplicity here by retaining the mutex. Use a
workqueue instead to queue the spring cleaning from IRQ context and then
do it when back in preemptible context.
Thx.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
next prev parent reply other threads:[~2019-04-16 9:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 1:20 [PATCH 1/2] ras: fix an off-by-one error in __find_elem() Cong Wang
2019-04-16 1:20 ` [PATCH 2/2] ras: close the race condition with timer Cong Wang
2019-04-16 9:58 ` Borislav Petkov [this message]
2019-04-16 17:09 ` Cong Wang
2019-04-16 17:42 ` Borislav Petkov
2019-04-16 18:00 ` Cong Wang
2019-04-16 18:06 ` Cong Wang
2019-04-16 9:07 ` [PATCH 1/2] ras: fix an off-by-one error in __find_elem() Borislav Petkov
2019-04-16 17:01 ` Cong Wang
2019-04-16 22:18 ` Luck, Tony
2019-04-16 23:18 ` Cong Wang
2019-04-16 23:28 ` Luck, Tony
2019-04-16 23:47 ` Cong Wang
2019-04-17 1:53 ` Luck, Tony
2019-04-17 2:31 ` Cong Wang
2019-04-17 2:37 ` Cong Wang
2019-04-17 21:15 ` Luck, Tony
2019-04-18 22:54 ` Cong Wang
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=20190416095852.GA31772@zn.tnic \
--to=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=xiyou.wangcong@gmail.com \
/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