Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3545375pxt; Tue, 10 Aug 2021 06:13:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPkWevzDvnKncEB+xyPLmkju1bYC0Dr6KVo6/ogfhpMeBXDDPLTdmX13eQNY111rZO/Dsx X-Received: by 2002:a1c:2202:: with SMTP id i2mr4745292wmi.78.1628601195255; Tue, 10 Aug 2021 06:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628601195; cv=none; d=google.com; s=arc-20160816; b=XcgM7xR5DmFo1zvVPhwU9Ir1pHij8gEwZgLR7jcwtvp2QKLYmbbd3KYW/Xc2zi7WoR zbyyG3i4oPi4aLOwZCsRzkOR1Yndn8NOw1ejkpiCqZrYHA8Cc71Osd9cstFtyHfln+pM xNfXW8vzk5cmQYbEQrELfiu7PG9BkuK1ecQ/AK8rJ3BpfRm+Sj0k+KMQP0ujSPvIVohU TiUYc/AXESay4y9SRWwg45OWKM45kk/ENJqfHWl8/TuYifK4YZ5HdwRaX6F8if8ZhRvy Vd1lYOxtB2u+l15WuB8FgtajU4xsbzpMeZoZ4mTiJdWjeg3iEC1jBkzlTrX4m0rHCckG AZqQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=iPMDSiID6HyjOwNCoieXyRQuimu3kmDXsXQXePe21EA=; b=T+bwrZB/AldRqe3BdalK91Fj2WtuIo4WYuGyLRYJrb+o0GjelNWppzLeS7SLndyX+y xKMpYtgoNhyIx5pBzI04DyL9y12kF7eSIvZnYr9Og9bcT5NMq+SyRL5/kNktErYjF5Kj hy7Ls9urh3cCCrd1vUrJPlQGiwrjgS0ZyKcvZcPCifvZb0pJNMOdnmDa49y0Nvnn85rM XzgssbHEwLxvbaFTw1RVLGobBMzhAQbXuYRtpiC+kexXgw/qsaqOyodPYbZNjm7HG54u PhO2wMSqGC8uN830PCfWlXZtKzFrbanrv0B+bqcq01iirAvY4DB7mF9s9WxWhnhkLvm7 rWIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=L61skdOO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z27si2204061ejf.565.2021.08.10.06.12.50; Tue, 10 Aug 2021 06:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=L61skdOO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238411AbhHJJu7 (ORCPT + 99 others); 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