From patchwork Wed Dec 6 17:36:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 845273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ysQlL2Pv6z9ryT for ; Thu, 7 Dec 2017 04:36:30 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3ysQlK5QhyzDrnn for ; Thu, 7 Dec 2017 04:36:29 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=permerror (mailfrom) smtp.mailfrom=kernel.crashing.org (client-ip=63.228.1.57; helo=gate.crashing.org; envelope-from=benh@kernel.crashing.org; receiver=) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3ysQl94g1WzDrcR for ; Thu, 7 Dec 2017 04:36:21 +1100 (AEDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id vB6HaGGi020551 for ; Wed, 6 Dec 2017 11:36:17 -0600 Message-ID: <1512581776.2224.129.camel@kernel.crashing.org> From: Benjamin Herrenschmidt To: skiboot@lists.ozlabs.org Date: Wed, 06 Dec 2017 11:36:16 -0600 X-Mailer: Evolution 3.26.2 (3.26.2-1.fc27) Mime-Version: 1.0 Subject: [Skiboot] [PATCH] timer: Stop calling list_top() racily X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This will trip the debug checks in debug builds under some circumstances and is actually a rather bad idea as we might look at a timer that is concurrently being removed and modified, and thus incorrectly assume there is no work to do. Signed-off-by: Benjamin Herrenschmidt --- core/timer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/timer.c b/core/timer.c index 4b5925fe..b10a5646 100644 --- a/core/timer.c +++ b/core/timer.c @@ -223,7 +223,6 @@ static void __check_timers(uint64_t now) void check_timers(bool from_interrupt) { - struct timer *t; uint64_t now = mftb(); /* This is the polling variant, the SLW interrupt path, when it @@ -231,9 +230,11 @@ void check_timers(bool from_interrupt) * the pollers */ - /* Lockless "peek", a bit racy but shouldn't be a problem */ - t = list_top(&timer_list, struct timer, link); - if (list_empty_nocheck(&timer_poll_list) && (!t || t->target > now)) + /* Lockless "peek", a bit racy but shouldn't be a problem as + * we are only looking at whether the list is empty + */ + if (list_empty_nocheck(&timer_poll_list) && + list_empty_nocheck(&timer_list)) return; /* Take lock and try again */