From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F855C4338F for ; Tue, 10 Aug 2021 09:50:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 279D461078 for ; Tue, 10 Aug 2021 09:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239305AbhHJJu7 (ORCPT ); Tue, 10 Aug 2021 05:50:59 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:42156 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232880AbhHJJu5 (ORCPT ); Tue, 10 Aug 2021 05:50:57 -0400 Date: Tue, 10 Aug 2021 11:50:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628589033; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iPMDSiID6HyjOwNCoieXyRQuimu3kmDXsXQXePe21EA=; b=L61skdOOHuxS+n1EgWhmZd0FQ8m1evWvHskeQrIEK46cdfK0o0iL+4mwSidMAo1rivQSfN 4aPeg0+1uykI8ruzHijioSWcinL1KuHLUKrLChHEYAAvrDjg3qpKsA0IY8FUVFVU1ADkt5 IB2338KYqGoyMni/E+tv2aBxkVyM4ZBZzA3Nm2KpI7rRAadhXXSz+WYIMVcbDpLXAfvqaM 3SVJ9JwqYvDwV2cIABevrLDlHpqCNnhlX35JslMzLUZCl0QWqUqjx65jAkwxczFxYQLrNt EqiGeO48efTkawogNyTYVkk6fZsQIq7P6TVd7ppcvl89S4CYap9NhmO0xgEGsw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628589033; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iPMDSiID6HyjOwNCoieXyRQuimu3kmDXsXQXePe21EA=; b=KY/MVKsZWQ0TD5d+8XmFYD2fCQzmUA8aG7KAHgxF6OYPZCJa7cFmg7GrT3o6IGTPqA0mkF szISeCjS3QM64nDQ== From: Sebastian Andrzej Siewior To: Clark Williams Cc: Thomas Gleixner , Steven Rostedt , Dmitry Vyukov , Andrey Konovalov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH PREEMPT_RT] kcov: fix locking splat from kcov_remote_start() Message-ID: <20210810095032.epdhivjifjlmbhp5@linutronix.de> References: <20210809155909.333073de@theseus.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20210809155909.333073de@theseus.lan> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-08-09 15:59:09 [-0500], Clark Williams wrote: > Saw the following splat on 5.14-rc4-rt5 with: =E2=80=A6 > Change kcov_remote_lock from regular spinlock_t to raw_spinlock_t so that > we don't get "sleeping function called from invalid context" on PREEMPT_R= T kernel. I'm not entirely happy with that: - kcov_remote_start() decouples spin_lock_irq() and does local_irq_save() + spin_lock() which shouldn't be done as per Documentation/locking/locktypes.rst I would prefer to see the local_irq_save() replaced by local_lock_irqsave() so we get a context on what is going on. - kcov_remote_reset() has a kfree() with that irq-off lock acquired. - kcov_remote_add() has a kmalloc() and is invoked with that irq-off lock acquired. - kcov_remote_area_put() uses INIT_LIST_HEAD() for no reason (just happen to notice). - kcov_remote_stop() does local_irq_save() + spin_lock(&kcov->lock);. This should also create a splat. - With lock kcov_remote_lock acquired there is a possible hash_for_each_safe() and list_for_each() iteration. I don't know what the limits are here but with a raw_spinlock_t it will contribute to the maximal latency.=20 > Signed-off-by: Clark Williams Sebastian