Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3582392imm; Mon, 6 Aug 2018 07:16:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpceh2BdtJ4V/f+imMkERTjLrcPpvtM8Wg+wstNH+rtnOG5hWKa8YcdzdADlYHKoBovkrCvC X-Received: by 2002:a63:df04:: with SMTP id u4-v6mr14634158pgg.434.1533564988149; Mon, 06 Aug 2018 07:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533564988; cv=none; d=google.com; s=arc-20160816; b=Lonsc0WOhzQm9hmvJYJk5B0XW/OY5Oc1Piwcr7bzT6oWPGjDr+rjNUYmf2nB2Gs+BE wYyZY9VRPDD6pN0JB1x8sN7NV8hGLqDDsJxND9arW8uy7UZTtrCatAqcVpuyVPtvN3jT fQflcRHReQFOe5yLu03VfijErgoPOXUKmCFGyjfmuJqqdyeFRkNbvpJ6xW3aXT0NcOPJ 5tbu68BZ3Mfvq2aS20n+inauDl1z7hUI62Mi4NWgGXIr6ipbMkTpJGaGZGGzbnEtgAOw /r6V5ow3xAXgCcmt25Of/ktC7C7gRyLG27tEzz7GGbfeGgcMgr1jSsy8NOyDNYTDbdKL 2tyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=adwqSUIV9AXhWIM3DwYWzpU9kAgWAroKPgJKcAG8VZk=; b=T3qmHCZZJsAnWhygddM8tMbT1wKViGXYJ+meGbYeExK279P2Ojb+3hLi6Wuw4AhDaK umZUyWBDZ7KH7XHTIIYEkNH2VHih9E/WiDABDIY5dOKHbnSi8PgAQR0SJpIeMs1V1nzT 3uiuRFHbv4KoFdCeZxKP7B7SnMewu586hVTw7l2TncNMgJ60AGauL6PG6cUCK4MUrC4z vGujcub+Kq7JvVls+s/GjxC2IAOfr43nH3zLliSC8t8eE8rpXjiV4URlR+lC5VYWC/al vZrCAyaCkDLpuYaVOoonJYtcyHFBHj5Y7okpT3LNRflgdzGQEQVQ1cFXjXYNcUKCOgKs HBxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=P8RdcgcM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1-v6si10340620pla.103.2018.08.06.07.16.13; Mon, 06 Aug 2018 07:16:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=P8RdcgcM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731524AbeHFQX4 (ORCPT + 99 others); Mon, 6 Aug 2018 12:23:56 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:45566 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727112AbeHFQX4 (ORCPT ); Mon, 6 Aug 2018 12:23:56 -0400 Received: by mail-yb0-f196.google.com with SMTP id h127-v6so5318063ybg.12 for ; Mon, 06 Aug 2018 07:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=adwqSUIV9AXhWIM3DwYWzpU9kAgWAroKPgJKcAG8VZk=; b=P8RdcgcMwcVeWUfcYA/1WmsIew3FS95aPdZP6qEu01EMbHGF+q407ozYNdbDC4aVcm DdpYcjAslGPGGeQoGK0VjusVNQmT9BCDEXJX8KwUgfAciKDPna8HM09Bq3UdZeKtd9Pu CAhWWXMNWKible3wMDpMd4ClahcbDmQGxCuV8f/Au5D6agkBf/fhwcnkKIe0XFNTRORl KJ/47RAUTscBVjBjuesQHXe5xsi8kVyA5TR7E2dY22wRlykM+lRnbY+/SrdP++wQWWtd 8vb4h3t8LA29QcZNe4zZgGneMTX9nCTo98SDNdY2H8zO2UfoerZSlSLAjWb3qr/BKTDU wDWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=adwqSUIV9AXhWIM3DwYWzpU9kAgWAroKPgJKcAG8VZk=; b=tTjJa8Qy0jjhQZN81MEu0aED8lMb7Mv0pwwU2F0QZ0NCmszV9rcCkQ/ctbTe9x7Isu OC5ZPFMkMaHPUjmFY82YwozOMNkOn+md5h5WGy861ZPSf33vasBW36POWZxWnrg1x9iV F4P7wWZaybgSzs9rzS0j+RAQyReHRt7VO0bzB9PjrGnXvtg8lWo0Ets2nTUmWjCGOsNP wYWedYCSX49pvBLEDZvDLuoKzTgpRsPPJ62383UUU00lCXBAqn+weAAxGNg09ZuH7u2K HWX8AMTrEbgfCoHkdzGpq8ePEqoxagZFj70lB8jDqw45keYDeB9tvf2ZJ7pPOtQEghbK LN5Q== X-Gm-Message-State: AOUpUlFgP0bEYunC/xrO3Bj1O2eg9Xa4VWtPU5P9s8GZp+onMbOAC7x/ 3QpWgVl1cdkOtQ7GOebhP41Fr559z9PFFT/rqrQvqw== X-Received: by 2002:a25:b94c:: with SMTP id s12-v6mr7521090ybm.91.1533564876220; Mon, 06 Aug 2018 07:14:36 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:bfce:0:0:0:0:0 with HTTP; Mon, 6 Aug 2018 07:14:35 -0700 (PDT) In-Reply-To: <20180806230536.ef217b2c2c008838606bedc3@kernel.org> References: <20180806034049.67949-1-joel@joelfernandes.org> <20180806230536.ef217b2c2c008838606bedc3@kernel.org> From: Joel Fernandes Date: Mon, 6 Aug 2018 07:14:35 -0700 Message-ID: Subject: Re: [PATCH ftrace/core] tracing: irqsoff: Account for additional preempt_disable To: Masami Hiramatsu Cc: "Joel Fernandes (Google)" , LKML , "Cc: Android Kernel" , Ingo Molnar , Steven Rostedt , Paul McKenney , Mathieu Desnoyers , Namhyung Kim , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 6, 2018 at 7:05 AM, Masami Hiramatsu wrote: > On Sun, 5 Aug 2018 20:40:49 -0700 > "Joel Fernandes (Google)" wrote: > >> Recently we tried to make the preemptirqsoff tracer to use irqsoff >> tracepoint probes. However this causes issues as reported by Masami: >> >> [2.271078] Testing tracer preemptirqsoff: .. no entries found ..FAILED! >> [2.381015] WARNING: CPU: 0 PID: 1 at /home/mhiramat/ksrc/linux/kernel/ >> trace/trace.c:1512 run_tracer_selftest+0xf3/0x154 >> >> This is due to the tracepoint code increasing the preempt nesting count >> by calling an additional preempt_disable before calling into the >> preemptoff tracer which messes up the preempt_count() check in >> tracer_hardirqs_off. >> >> To fix this, make the irqsoff tracer probes balance the additional outer >> preempt_disable with a preempt_enable_notrace. > > I've tested it and ensured this fixes the problem. > > Tested-by: Masami Hiramatsu Thanks! >> The other way to fix this is to just use SRCU for all tracepoints. >> However we can't do that because we can't use NMIs from RCU context. >> >> Fixes: c3bc8fd637a9 ("tracing: Centralize preemptirq tracepoints >> and unify their usage") >> Fixes: e6753f23d961 ("tracepoint: Make rcuidle tracepoint callers use SRCU") >> Reported-by: Masami Hiramatsu >> Signed-off-by: Joel Fernandes (Google) >> --- >> kernel/trace/trace_irqsoff.c | 26 ++++++++++++++++++++++++++ >> 1 file changed, 26 insertions(+) >> >> diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c >> index 770cd30cda40..ffbf1505d5bc 100644 >> --- a/kernel/trace/trace_irqsoff.c >> +++ b/kernel/trace/trace_irqsoff.c >> @@ -603,14 +603,40 @@ static void irqsoff_tracer_stop(struct trace_array *tr) >> */ >> static void tracer_hardirqs_on(void *none, unsigned long a0, unsigned long a1) >> { > > To ensure this function must not be preempted even if we increment preempt > count, I think you should check irq_disabled() whole this process, put below > here. > > if (unlikely(!irq_disabled())) > return; > > Since irq_disabled() will be checked in irq_trace() anyway, so no problem > to return here when !irq_disabled(). IRQs can never be enabled here. The trace hooks are called only after disabling interrupts, or before enabling them. Right? thanks, - Joel