Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4274466pxt; Wed, 11 Aug 2021 02:02:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdX/pT3pjVr0nX8qP/thT4ESrfXYXIB3iRRom2nEbUzv9ibjxRPcMBZy2BIF1W/weFQj8X X-Received: by 2002:a17:906:fcd7:: with SMTP id qx23mr2629051ejb.267.1628672543674; Wed, 11 Aug 2021 02:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628672543; cv=none; d=google.com; s=arc-20160816; b=lSAbD4pkNVxzOjr+gu4g/dim2CRodMgdKad7CswIBi/WBV4H7e9pqKhQXevpVwlzUh 86+JTFD9gxTIqUwewP83PnhMJVZM6aZO20JfMuqyaCaF+eSk1q/cBr0IYtokuubtew4x PQRgopKgRqnUhuM3Q+k9tw6fIhxXdd5M5t9IeCwldO36mZaUUwruJ7ewmeu8xWr5TLM2 Z/jDlSc5X+3RDI9rgtnN8BwQLv8ZSdv4Q5fx3bDHQdlMyzD6bZoPdyIa/qaD+zWq0r17 dS693qqf0O1C0gP01LfQq7ahAN6BLGaimULOxTodh6kVrV+YARGZOwuSKZfD/0Z2mnGT W+KA== 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=6NUQ3TyOknPB3iraV2OgTTMR9Er1TbuGJXWQNUYkDqU=; b=GImYbp0ktU7uK2l41pmJSvhXq31FXSs6s4Ecp7YnP+J1tg7l2zr55bs1k4sWOdgmcE xE347lv8GJlM9IAQDnRnEeJmaZ/DP03ZmU6eoDO5eUk55g58yR0eEGB0Ic70sXPPY0lR Ou4dI7FDXmlShtCbas4Uea0hKhoaHl5ynGnVjHOvEm8PNnUBW6+ZaObI9v7XeiZp+pC0 m4f3jBB8cbe36kdZ4M7aBJhsn9WeDFqnlLgPjRv5bdjW4hRnboKTKqFYneTTPhcb5ajd QVFJOChn7f15PGXL8DPvIRAIP4xxlAd7bf/TRwAY5EyyI9ElWURbOYY9AIYxgkscixtz nDLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=u6BMEXBN; 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 n9si21720672edw.373.2021.08.11.02.01.59; Wed, 11 Aug 2021 02:02:23 -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=u6BMEXBN; 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 S236348AbhHKJA7 (ORCPT + 99 others); Wed, 11 Aug 2021 05:00:59 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:48982 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232734AbhHKJA7 (ORCPT ); Wed, 11 Aug 2021 05:00:59 -0400 Date: Wed, 11 Aug 2021 11:00:33 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628672434; 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=6NUQ3TyOknPB3iraV2OgTTMR9Er1TbuGJXWQNUYkDqU=; b=u6BMEXBN2yeUctjIs2HApfcf8dYyn07sY99LQ8uM7znA/yEGZJ3w5pbH1Ihhe4qMzSo7ac qPk2YuOa0X83kkOF7savnE+eF4l2NRb2CzvsLr+K/hRm01IcO0USiHbd3WfyQzVWOQ2bMY ZWkBvoACEIwqtnDfHIcew7aEvDIIUlibFZStW+vF95v3VQdkPjWJI9EpSoIm8qjOV0ONjd FiM19UMKXxhPoM/GLl+4ins5GJ6DylaIYMPNLrg4OBQfjleTkpWVmZxVff9xQFSgCIt9DW 7+WnFnvuZW4gBzd8FMUbO3DsQKLWNjNz2WS0gRme/jsd4tEK+A3289WpZv4taw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628672434; 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=6NUQ3TyOknPB3iraV2OgTTMR9Er1TbuGJXWQNUYkDqU=; b=ZIrd3wXtGnh9Qa9T0DZIudsTeT22ZUnv/O7EwgJ6VjkxgYCf8DcfKdk+++agUZEVnUVbPz slaKnDd/5GHqLpAg== From: Sebastian Andrzej Siewior To: Thomas Gleixner Cc: Clark Williams , 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: <20210811090033.wijh4v37wlnny3ox@linutronix.de> References: <20210809155909.333073de@theseus.lan> <20210810095032.epdhivjifjlmbhp5@linutronix.de> <87sfzhox15.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <87sfzhox15.ffs@tglx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-08-10 22:38:30 [+0200], Thomas Gleixner wrote: > 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 t= hat > >> we don't get "sleeping function called from invalid context" on PREEMP= T_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. >=20 > Which does not make it raw unless we create a raw_local_lock. But why raw? I was thinking about local_lock_irqsave() instead of local_irq_save() and keeping the spinlock_t. > > - kcov_remote_reset() has a kfree() with that irq-off lock acquired. >=20 > That free needs to move out obviously >=20 > > - kcov_remote_add() has a kmalloc() and is invoked with that irq-off > > lock acquired. >=20 > So does the kmalloc. >=20 > > - 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 >=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. I wasn't aware of that. However, with that local_irq_save() -> local_lock_irqsave() swap and that first C code from Documentation/dev-tools/kcov.rst I don't see any spike in cyclictest's results. Maybe I'm not using it right=E2=80=A6 > Thanks, >=20 > tglx Sebastian