Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp752678pxb; Thu, 23 Sep 2021 09:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlswUZBA6hVJa3cwRvdJRPsG1QqdHFteqWsD4rBxzNrqvG1Aepp8zl+SHLPizetI4pgD1r X-Received: by 2002:a17:906:c1da:: with SMTP id bw26mr6124085ejb.253.1632415978431; Thu, 23 Sep 2021 09:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632415978; cv=none; d=google.com; s=arc-20160816; b=dI5Ck/jFxl25cm6vy2CORh9HgErBJzGbtaqVqjLrVh67UuXLCQ4AAZ2qU5gMm+olB3 UUd2vIiEc0ypCkbwbGPxSyCVvTpok7mcA9tqsaDTq/uP/TzxJuJ8LAeFrV282iCDiUle 939IszY/2dHT6CNX66OU/RcmWBO+Y2glWWw/GXIwylodfZkQZwylsyN+oohT0sJqJYrz zOVixDAgyMbLMKPhVv66b1MQPjzkRI6J0d/8JFnN/9KV9bH0j6jx3yflPT9f6/e6lADD 3FYlgsS64WQ1lESEKRE4TxmvID9S1sB97U6GXMk7wugtyZ5J/aXs77tfeaeC6pvpDLHf 9FSg== 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 :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=Vi5RWc6YZLQPlGlsSLEKEH6yFrTkfKkQNlRzcTZMmK0=; b=DruHE8NUEquP2Sn4gwKu4d6lDqmsx6nGIZsVqI2oss3zxji6JL8B9JbMGRhQCeTipz HmJ7puYcRPYJACnWoX4nvsX4gEc4JDyCGulQRQ7cn7F8uANrGtXSiqgnlrRIQs0gRAm8 F7oD5taoJMCdVqisH3Lfdy00TVcRh0ibRZKcxcgF7Kp1ivA9tBXMjblKULsLMG+1fREr XAwpFwIEhwjWIPBALV8ArWQPfzgEcwwCSD4LuxfO0207j1r5G+87UmmTzZ+bUZ7XOch3 qEeCUj1ORSDEAklKHqawos44GfaL+oRAjJy1akru9dfJK1vDy7GoNwlGcVer+/1GjtxU NpVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Bgn0atER; 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 j23si7730715eje.21.2021.09.23.09.52.33; Thu, 23 Sep 2021 09:52:58 -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=Bgn0atER; 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 S242166AbhIWQtk (ORCPT + 99 others); Thu, 23 Sep 2021 12:49:40 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:35878 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235221AbhIWQtW (ORCPT ); Thu, 23 Sep 2021 12:49:22 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1632415670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vi5RWc6YZLQPlGlsSLEKEH6yFrTkfKkQNlRzcTZMmK0=; b=Bgn0atERrUNvHTzYENlPr0cnhm00ZYx8HlPtgCw+qRp7ZtkS9h/N3Wk6or2ysnJn7a0Afm 26Vb5MxjgHXJW1Oideg0QLRPOXYUxMV4VGDWreJ+i74Fxnj9QPSSWNPkitBWLQTHb1ijzt fuphfk5InnwhsOM6k2LM6Qs+eWyovaQGvsPqI+FyajTWUM+jdCmrfM3aTql6kP6kA4kzxZ 2ymIkKo2gxNo/MeKz1nle6gRdKoYayQoU06zJz0smYvDc5KUQTE0Cu9hTjpakjR1ib/8nZ dzO3FiJW8kQVTK4xk2i/DRZrhUOeIcklA3b3M3tHQTcnhNfWocLxNKznqFtq7A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1632415670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vi5RWc6YZLQPlGlsSLEKEH6yFrTkfKkQNlRzcTZMmK0=; b=hPyPg9J7+L7N2j//adKoTJAzG0+sQ5Bqsu6ZcemI7sPyPWeBYgMBs3TxKRIokj+YR8RM51 p9zFdR4ydqCD8lDw== To: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Andrey Konovalov , Thomas Gleixner , Steven Rostedt , Marco Elver , Clark Williams , Andrew Morton , Sebastian Andrzej Siewior Subject: [PATCH v2 4/5] kcov: Avoid enable+disable interrupts if !in_task(). Date: Thu, 23 Sep 2021 18:47:40 +0200 Message-Id: <20210923164741.1859522-5-bigeasy@linutronix.de> In-Reply-To: <20210923164741.1859522-1-bigeasy@linutronix.de> References: <20210923164741.1859522-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kcov_remote_start() may need to allocate memory in the in_task() case (otherwise per-CPU memory has been pre-allocated) and therefore requires enabled interrupts. The interrupts are enabled before checking if the allocation is required so if no allocation is required then the interrupts are needlessly enabled and disabled again. Enable interrupts only if memory allocation is performed. Signed-off-by: Sebastian Andrzej Siewior Acked-by: Dmitry Vyukov Acked-by: Marco Elver Tested-by: Marco Elver Link: https://lore.kernel.org/r/20210830172627.267989-5-bigeasy@linutronix.= de --- kernel/kcov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/kcov.c b/kernel/kcov.c index 4f910231d99a2..620dc4ffeb685 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -869,19 +869,19 @@ void kcov_remote_start(u64 handle) size =3D CONFIG_KCOV_IRQ_AREA_SIZE; area =3D this_cpu_ptr(&kcov_percpu_data)->irq_area; } - spin_unlock_irqrestore(&kcov_remote_lock, flags); + spin_unlock(&kcov_remote_lock); =20 /* Can only happen when in_task(). */ if (!area) { + local_irqrestore(flags); area =3D vmalloc(size * sizeof(unsigned long)); if (!area) { kcov_put(kcov); return; } + local_irq_save(flags); } =20 - local_irq_save(flags); - /* Reset coverage size. */ *(u64 *)area =3D 0; =20 --=20 2.33.0