Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3879205pxt; Tue, 10 Aug 2021 13:39:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8yzI1ofscQHGsX/fXKEpllVQUwAgomBOG81GGcA68m5/CbXX2Uicg0x7mOLPhITBCbiU3 X-Received: by 2002:a05:6e02:4d2:: with SMTP id f18mr233231ils.21.1628627970315; Tue, 10 Aug 2021 13:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628627970; cv=none; d=google.com; s=arc-20160816; b=hDsEqwWQNEXCA/Qn8rIkMhRqjU/HvAc3ty9+rbaK6apZIifn3gQ2y3QXwNC6Dluhtt QQDJgg4zKN+mb4txW6peOrpSjHFPZ9tbevbu4PDf7eAHZoaqxQcevnVVtKnPS/KpGmD3 rNQzdsaTQzrvSFTw9HsUOnDuxT1KCg4iGBZ9Fcc6gNEU4Hq+fFfMp4FlRThBI7xne/Ta 3SFcohlWqAMpVM/7GN4YmFG2JMHWB4MVmQTdO9X0hS/S1pRX4c5JpJQh7Uqa6wfKp1N0 DQIzXzEhiIZpdkMQOxRL3ZHOYNxvPQ8Kyy/oOWvH+feCHf3Xl5JgRv0xOaHVZP92RhZg FaWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=PkVtjYm3BfNCg+SbthLRj+WEbFU9jkunNTtXTBea3V4=; b=MbXoZI42Dl9SjY9+BLUTkIaqax4XezzIa+YW6kHragHsHeppciJdKq+wkADb/7XQW5 sA11zPMjLL+eep7idc6574FPqVRAq0ajEs9cjCvK3A0NjKupu59+06RO3bI9wuoHJtlx onXmkldCdbcZe8gxs/1QjLm+RzAZPAMGt3knrcbV7a95OponcUX9xFe4zWCSesqxHaGA QIOnwFtjkwIFSTEnl729CDhMLMo+GI416CLC5dsGFMGgBJ8FlaRMgMUZoaK+6kLIG4BO fkxcMDgj/r4j6v+3zZRiW+aRKyKoxyli9+aDj/0d3ELEyK0PWW606p6KwxMnV1oAdJaW LGFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Y/oBbb4F"; dkim=neutral (no key) header.i=@linutronix.de; 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 n14si26846770ilk.78.2021.08.10.13.39.16; Tue, 10 Aug 2021 13:39:30 -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="Y/oBbb4F"; dkim=neutral (no key) header.i=@linutronix.de; 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 S230295AbhHJUi4 (ORCPT + 99 others); Tue, 10 Aug 2021 16:38:56 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:45796 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbhHJUiy (ORCPT ); Tue, 10 Aug 2021 16:38:54 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628627911; 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=PkVtjYm3BfNCg+SbthLRj+WEbFU9jkunNTtXTBea3V4=; b=Y/oBbb4FW3u8yktuwVCeGFD164Laq+BYDynM0nVW9KRLRPJHvV+2m60JsEMFm79ERanvev NuZZywbDhDV07G86qQbwXG1MTBxysxW2i1tuOOnIyqMWSmQT8r7luxCCu1H1mb+nZij9VE vhh4fTNg+wwXQKyWJ+P2DnERF/NxuRaBuoIO8TvpQaq/GmV+i3Oy1WLXnaJ3ZU+MGCBWMb tDh9tjfCDjeZ1hBdhHjBzp2dyDKJlYZGbjMPksgQOBGGNWkzrN46QNqmkoaPMHOSGmZ1ZX P6NEByuvsNbEJH38ly92/JvRbogZRZk/a2KxlFgcQwVzVdVmiBCMGipnKxFnfA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628627911; 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=PkVtjYm3BfNCg+SbthLRj+WEbFU9jkunNTtXTBea3V4=; b=Yf3Ht3y3955z1yV0IKDS3aUnunEjBXY+XP4xTvfitS/jfvKJUs50PBQ7WVqbXS5KyhOEFt CLyWve4MQ+5GxrCw== To: Sebastian Andrzej Siewior , Clark Williams Cc: 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() In-Reply-To: <20210810095032.epdhivjifjlmbhp5@linutronix.de> References: <20210809155909.333073de@theseus.lan> <20210810095032.epdhivjifjlmbhp5@linutronix.de> Date: Tue, 10 Aug 2021 22:38:30 +0200 Message-ID: <87sfzhox15.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10 2021 at 11:50, Sebastian Andrzej Siewior wrote: > 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_= RT 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. Which does not make it raw unless we create a raw_local_lock. > - kcov_remote_reset() has a kfree() with that irq-off lock acquired. That free needs to move out obviously > - kcov_remote_add() has a kmalloc() and is invoked with that irq-off > lock acquired. So does the kmalloc. > - 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 And that matters because? kcov has a massive overhead and with that enabled you care as much about latencies as you do when running with lockdep enabled. Thanks, tglx