Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp881357rdb; Fri, 20 Oct 2023 02:03:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnTCOmfAwVDrxlsJ1bumMqNyv+ke4nRH8oivvY1y1WuEgS1v69XmLGYK/WrSMmqwl/QCSd X-Received: by 2002:a05:6808:1ce:b0:3a7:4914:23ce with SMTP id x14-20020a05680801ce00b003a7491423cemr1226958oic.18.1697792606687; Fri, 20 Oct 2023 02:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697792606; cv=none; d=google.com; s=arc-20160816; b=cd9gu8HcniItzDz8YUAg729r2PNg/2jQvKhKKO7OVo/QzWBcI7NstVed7nBgPjgI7R yy3u+yIOe7GndGuWKbV1h2y+CW/QzxRpyd7EY90a4+fWOFwoQmHec8BYuSqGwpEjbkDi gv+w0PGTi0azm5KCoP5lqaTKV8fSHJhehec+RkxzjpuGyO7YuVGtAfdIlxp/LSDmWcH3 iUJmoiFv8rGUdLC3nsG9OKRAyzVna+YbdWazRMhHHtlh4uB08+obNlyTOEY+8JPuoVoJ JzEyPJ8+s/L3ewqCQC5KpMNU8gq//dex8qx/4DFFkLs9deSav5Lfy8ZFNQ2WSBTyLPoX PJ+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=AlWarTiBrVKN0IicVfyeqlDJwebAqfMrHUe7mm3ynGk=; fh=rH2hMSJzgCBkKe6bCkWLqX4g3UplW+m0whLxPkO/O7k=; b=CRcB8ndpMo2tO9+wYzQWgT0Oio4kIp3yd4Iamjxz59lj/uIqRYw34t0RH+rkwnbNMf Y2JUvJ3W1QaaCagkEa3531rlH6hI+UcImB7cVqaQS7kFhUDGtdDdKHReos9tFnTiX3Kn 9hh6y7isc/W+m/g5uiYmd/4316WXlVCL6b8bui2yfB0j5mYl0KVF+1cQgW7FR3Xe1pLE OwUyuzSjsRUeJj4NtQ8zFw47JtbuhyTF1FeWAJxzEHNrnuHb6mgnh1I7ysqgS62VGIjx ismhhyT1jm585zUD2adN/8LbB4wcZwHI2lSW3+FS5770l7vWQ/4m30VUFxh2S81bsrZZ +F1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mBXQMLdZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=RiZcwS8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r20-20020a6560d4000000b005ac8d44bad4si1320818pgv.592.2023.10.20.02.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:03:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mBXQMLdZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=RiZcwS8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5AD9683348BD; Fri, 20 Oct 2023 02:03:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376572AbjJTJCy (ORCPT + 99 others); Fri, 20 Oct 2023 05:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376554AbjJTJCw (ORCPT ); Fri, 20 Oct 2023 05:02:52 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E4AFD46 for ; Fri, 20 Oct 2023 02:02:50 -0700 (PDT) Date: Fri, 20 Oct 2023 11:02:45 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697792567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AlWarTiBrVKN0IicVfyeqlDJwebAqfMrHUe7mm3ynGk=; b=mBXQMLdZZY2DsaoUkW4yVJ05JdY14sRnFHRhiKCHo9gxrQie010QKeyCv32huN2sy2A2Nb D7yMuGZPotIH4soROIIi+yJrLg4A/8+8whQGDgwGHOKGcS6t22ZD+OKac+N0x/24XZULEY HTpB1IHZYNeqS8SDJFVowkbfV8fFCD7dqNUWJDuyBWan41HPLyRh5apwEnwJOMSgk/uXN/ Xmoi0pCZFNRz2P2KpRh2qbZ50B/i/BW5sK/i/RsepQ0Rdg+/tJB9FS2CS80lVrqEYN0xgr LoPaW0C/6GuoYYPXXlvlCfUs9e6tagKrULrGuiOFfGkfUSmnBISt67LjMbZ6NQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697792567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AlWarTiBrVKN0IicVfyeqlDJwebAqfMrHUe7mm3ynGk=; b=RiZcwS8UDaYLOzEgorSk4g5RyvjO6lUYJxS+DOkNJdg/67+1Wk04U40j/ZwMjBhsgKH+g+ oEgpxMYpV5LmK+AA== From: Sebastian Andrzej Siewior To: Thomas Gleixner Cc: John Stultz , Tetsuo Handa , Stephen Boyd , LKML , "Paul E. McKenney" , x86@kernel.org Subject: Re: [PATCH] clocksource: disable irq when holding watchdog_lock. Message-ID: <20231020090245.cPAViz09@linutronix.de> References: <80ff5036-8449-44a6-ba2f-0130d3be6b57@I-love.SAKURA.ne.jp> <878r826xys.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <878r826xys.ffs@tglx> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:03:09 -0700 (PDT) On 2023-10-16 23:47:55 [+0200], Thomas Gleixner wrote: > But the explicit local_irq_disable()/enable() pair around the readout > means that the patch above is obviously broken: > > spin_lock_irqsave(&watchdog_lock, flags); > cs_watchdog_read() > local_irq_disable(); > ... > local_irq_enable(); <--- FAIL > > Lockdep should have yelled at that too, but even if it failed to do > so then it's still very obviously wrong. Lockdep will shout from local_irq_enable() if the lock is still held. That is working and I just verified it. However I didn't get to that part in cs_watchdog_read() in my testing so that might be why lockdep didn't complain in Tetsuo's case. After adding a irq-enable before the unlock for lockdep-testing I did see the splat. > Something like the uncompiled/untested below should cure it for real. It > really does not matter whether the TSC unstable event happens a bit > later. The system is unhappy no matter what. The snippet below is perfect :) > That said, this whole clocksource watchdog mess wants a proper > overhaul. It has become a pile of warts and duct tape by now and after > staring at it long enough there is no real reason to run it in a timer > callback anymore. It just can move into delayed work and the whole > locking problem can be reduced to the clocksource_mutex and some well > thought out atomic operations to handle the mark unstable case. But > that's a different story and not relevant for curing the problem at > hand. A pile of warts. Okay. This explains why the lock is acquired everywhere with irqsave while in-IRQ access is not desired. > Thanks, > > tglx Sebastian