Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1194315imm; Wed, 8 Aug 2018 12:26:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwU6vztJ9g9+3jWBFz1ez7q3gQHTPf4oeWOJPr4EIr+mNCPYZ2vmnv0yj0hdCx0hj0mlRHZ X-Received: by 2002:a63:3c0c:: with SMTP id j12-v6mr3674422pga.440.1533756363849; Wed, 08 Aug 2018 12:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533756363; cv=none; d=google.com; s=arc-20160816; b=JFjzYiEYqt0g2QDCTktKZzYaE4JVX/lOir94dnTYuYOo5oOCz1ogR/2JiizKzwsWd+ tI9VxWauZMwfgKQBza5LcZGIv4TMD+1TnnNwHEkX/V+tfqoBN/OlEM8QxUx1FmwHzNfg OwnwUrgmt2/Vc/Z+V0COjzcz5Lfo4rmViRvzQ7E4Mx9cOYE7uL4AUJKlFC/qUg6ZhqSP Q/SHMtqJKXs5C02v6+/LNQWsNJafTETWnBSRm4UarPF2eSNgjUEYCFc3b5lp/1aL2GBh xMKXksNQbbo96LH2j4ef/4CrCJAKmBMGU0nhH0kTkhLQccaxERBMpDbVBs+B5RLYI+i6 GkJg== 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=MOPlefY8BPTdz7pSeX12AWm3e7jwz7gDDdSoI4SDW8I=; b=UPoW3pHjnxcrQ3pIg3j5cxgbVtTp5y0hj2cPmeB5lavjUco+c1DgPR5yhEx+7fWgJe gOmsYNr+mqU7OnNzUlUEJ17y1gOW+yjwK1si35U5+FIEJQ1ClNJhervnFHWQoainqglz nZiFRLX9t/WI+fxrqdNEZU1azyTOtlGw63bPod5jhlcsjzDcbye+rYRP93K1FyScacsg hi3bZnNaadfgSgifPi8+e3LIW1y2qohLjBEGQx5AfAiBHnkxYQ2qtW9K3t/qwUHhMGVm uz3CmQzy48R2pr55nTajSzwBhD1Y3gITjQV/r9+qcdVjMQIUdVhND8K92vTbLBSfQFAo HQ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=J30EaJxF; 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 c5-v6si4837148pgk.327.2018.08.08.12.25.48; Wed, 08 Aug 2018 12:26:03 -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=J30EaJxF; 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 S1730729AbeHHVp3 (ORCPT + 99 others); Wed, 8 Aug 2018 17:45:29 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:35332 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbeHHVp2 (ORCPT ); Wed, 8 Aug 2018 17:45:28 -0400 Received: by mail-yw1-f67.google.com with SMTP id s68-v6so2417366ywg.2 for ; Wed, 08 Aug 2018 12:24:22 -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=MOPlefY8BPTdz7pSeX12AWm3e7jwz7gDDdSoI4SDW8I=; b=J30EaJxFj71gi+Btey1tf14eKqRYroRXsJj+FxMZ+jEsoit+PFiIWI2k4hE3G7jZRm fm0w3aqZlcbMrCfeUm9jwymUuMEyvuza+/H8vVsc3JsWv+tm4T9Ku4d/VtA7wh09Lbdw tnuje1hdIK99G2U9K+RHXSU8nIgcs0OmbY2J5Uz//PDHhmLtczLCrbGGyasxg6pVm93O lO7Zi6PJjEoXNdf8FKlNf+8kkE4gQPl4jnaKjC1OgSSoo8wBIrmmPsmX/iwb9n+iiJYk feqpvOvqm8C0DJduIcfIYtIp2qjC3DojfzIR5WLjFRyxZZ/4swdp6v/XmCVdPRLnqLEW pH5Q== 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=MOPlefY8BPTdz7pSeX12AWm3e7jwz7gDDdSoI4SDW8I=; b=Bqh23MTy58/V+Bk3q5yL5tgrTJ7/wK4L8X1uaDhnwdzvKR6hADZokrI8Lyz1Ehfd0E RjV+LtBfBAF1Y+YWBxAbrk9A8fGx24u6WgWzV8fPaHJaelxKUj296thuh09z55ApMbsr Fd/AaxjWCcgG9hIrLnwSZtiZgFxCnGLd0BY8TQQ7i1i6zFazlf6d9EoaYCyYzD77mzz8 T4vhP7qNEto+w4sF/seeSXSVoYIBgJM61oQfLFmR0aRIH9uqdg6k8JYi3SrIKZ66AKBI pa9Emabdah9ehXYRYblBtdvCPwdt2+/Y57PzV+TQMs7NNWYth2bQT1hkn+jVTVX0p28n gA5g== X-Gm-Message-State: AOUpUlERcPC0Si55D/1ttzuF/z414ngcVlx4P1t1tsZdU3N/w9+pP9wx ZLoRavoPoCDXEQlvYtFtoHHDczmRpVya1bqC53vOILHw+T0= X-Received: by 2002:a0d:d981:: with SMTP id b123-v6mr2184991ywe.64.1533756261094; Wed, 08 Aug 2018 12:24:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:bfce:0:0:0:0:0 with HTTP; Wed, 8 Aug 2018 12:24:20 -0700 (PDT) In-Reply-To: <20180808144922.GN24813@linux.vnet.ibm.com> References: <6D0A3FD6-2190-4CC0-A3C0-7B3759E73243@google.com> <20180807204820.50b83c6d@vmware.local.home> <20180807215522.04114097@vmware.local.home> <20180807222856.3ede96e7@vmware.local.home> <20180808130041.GI24813@linux.vnet.ibm.com> <20180808144922.GN24813@linux.vnet.ibm.com> From: Joel Fernandes Date: Wed, 8 Aug 2018 12:24:20 -0700 Message-ID: Subject: Re: [PATCH v12 3/3] tracing: Centralize preemptirq tracepoints and unify their usage To: Paul McKenney Cc: Steven Rostedt , Joel Fernandes , LKML , "Cc: Android Kernel" , Boqun Feng , Byungchul Park , Ingo Molnar , Masami Hiramatsu , Mathieu Desnoyers , Namhyung Kim , Peter Zijlstra , Thomas Glexiner , Tom Zanussi 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 Wed, Aug 8, 2018 at 7:49 AM, Paul E. McKenney wrote: [...] > >> In that case based on what you're saying, the patch I sent to using >> different srcu_struct for NMI is still good I guess... > > As long as you wait for both SRCU grace periods. Hmmm... Maybe that means > that there is still a use for synchronize_rcu_mult(): > > void call_srcu_nmi(struct rcu_head *rhp, rcu_callback_t func) > { > call_srcu(&trace_srcu_struct_nmi, rhp, func); > } > > void call_srcu_nonmi(struct rcu_head *rhp, rcu_callback_t func) > { > call_srcu(&trace_srcu_struct_nonmi, rhp, func); > } > > ... > > /* Wait concurrently on the two grace periods. */ > synchronize_rcu_mult(call_srcu_nmi, call_srcu_nonmi); > > On the other hand, I bet that doing this is just fine in your use case: > > synchronize_srcu(&trace_srcu_struct_nmi); > synchronize_srcu(&trace_srcu_struct_nonmi); > > But please note that synchronize_rcu_mult() is no more in my -rcu tree, > so if you do want it please let me know (and please let me know why it > is important). I did the chaining thing (one callback calling another), that should work too right? I believe that is needed so that the tracepoint callbacks are freed at one point and only when both NMI and non-NMI read sections have completed. >> >> It does start to seem like a show stopper :-( >> > >> > I suppose that an srcu_read_lock_nmi() and srcu_read_unlock_nmi() could >> > be added, which would do atomic ops on sp->sda->srcu_lock_count. Not sure >> > whether this would be fast enough to be useful, but easy to provide: >> > >> > int __srcu_read_lock_nmi(struct srcu_struct *sp) /* UNTESTED. */ >> > { >> > int idx; >> > >> > idx = READ_ONCE(sp->srcu_idx) & 0x1; >> > atomic_inc(&sp->sda->srcu_lock_count[idx]); >> > smp_mb__after_atomic(); /* B */ /* Avoid leaking critical section. */ >> > return idx; >> > } >> > >> > void __srcu_read_unlock_nmi(struct srcu_struct *sp, int idx) >> > { >> > smp_mb__before_atomic(); /* C */ /* Avoid leaking critical section. */ >> > atomic_inc(&sp->sda->srcu_unlock_count[idx]); >> > } >> > >> > With appropriate adjustments to also allow Tiny RCU to also work. >> > >> > Note that you have to use _nmi() everywhere, not just in NMI handlers. >> > In fact, the NMI handlers are the one place you -don't- need to use >> > _nmi(), strangely enough. >> > >> > Might be worth a try -- smp_mb__{before,after}_atomic() is a no-op on >> > some architectures, for example. >> >> Continuing Steve's question on regular interrupts, do we need to use >> this atomic_inc API for regular interrupts as well? So I guess > > If NMIs use one srcu_struct and non-NMI uses another, the current > srcu_read_lock() and srcu_read_unlock() will work just fine. If any given > srcu_struct needs both NMI and non-NMI readers, then we really do need > __srcu_read_lock_nmi() and __srcu_read_unlock_nmi() for that srcu_struct. Yes, I believe as long as in_nmi() works reliably, we can use the right srcu_struct (NMI vs non-NMI) and it would be fine. Going through this thread, it sounds though that this_cpu_inc may not be reliable on all architectures even for non-NMI interrupts and local_inc may be the way to go. For next merge window (not this one), lets do that then? Paul, if you could provide me an SRCU API that uses local_inc, then I believe that coupled with this patch should be all that's needed: https://lore.kernel.org/patchwork/patch/972657/ Steve did express concern though if in_nmi() works reliably (i.e. tracepoint doesn't fire from "thunk" code before in_nmi() is available). Any thoughts on that Steve? thanks! - Joel