From patchwork Thu Oct 5 19:15:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 9987821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F259D6029B for ; Thu, 5 Oct 2017 19:15:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E703628D43 for ; Thu, 5 Oct 2017 19:15:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBDC928D47; Thu, 5 Oct 2017 19:15:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7914328D43 for ; Thu, 5 Oct 2017 19:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751880AbdJETPX (ORCPT ); Thu, 5 Oct 2017 15:15:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751766AbdJETPW (ORCPT ); Thu, 5 Oct 2017 15:15:22 -0400 Received: from gandalf.local.home (cpe-67-246-153-56.stny.res.rr.com [67.246.153.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BFF221907; Thu, 5 Oct 2017 19:15:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BFF221907 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Thu, 5 Oct 2017 15:15:17 -0400 From: Steven Rostedt To: Arnaldo Carvalho de Melo Cc: Julia Cartwright , bigeasy@linutronix.de, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Clark Williams , Dean Luick , Dennis Dalessandro , Doug Ledford , Kaike Wan , Leon Romanovsky , linux-rdma@vger.kernel.org, Peter Zijlstra , Sebastian Andrzej Siewior , Sebastian Sanchez , Thomas Gleixner , "Marciniszyn, Mike" Subject: Re: [PATCH 1/2] IB/hfi1: Use preempt_{dis,en}able_nort() Message-ID: <20171005151517.0c948504@gandalf.local.home> In-Reply-To: <20171005185330.GP25388@kernel.org> References: <20171003154920.31566-1-acme@kernel.org> <20171003154920.31566-2-acme@kernel.org> <20171005141744.GC21185@jcartwri.amer.corp.natinst.com> <20171005165305.GN25388@kernel.org> <20171005182900.GK647@jcartwri.amer.corp.natinst.com> <20171005185330.GP25388@kernel.org> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 5 Oct 2017 15:53:30 -0300 Arnaldo Carvalho de Melo wrote: > Em Thu, Oct 05, 2017 at 01:29:00PM -0500, Julia Cartwright escreveu: > > On Thu, Oct 05, 2017 at 01:53:05PM -0300, Arnaldo Carvalho de Melo wrote: > > > So __this_cpu_inc() checks preemption but this_cpu_inc() doesn't and > > > thus we're ok here? Or am I getting lost in this maze of defines? :-) > > > I think I was the one lost in the maze. You are correct. Sorry for the > > confusion. > > > My mind expected that the __ prefixed versions would be the "raw" > > versions that are free of checks, with the checks made in the non > > prefixed versions, but it is the other way around. > > > I'm happy to accept that the bug is within my mind. > > :-) > > Ok, now I'm taking the opportunity to read more about local locks, as > Sebastian thinks are needed in this case, which I'm not entirely > convinced from the discussion that took place here, and as you took part > in that discussion and suggested using the nort variants of > preempt_disable, do you still think this is the way to go? > Looking at http://lkml.kernel.org/r/32E1700B9017364D9B60AED9960492BC3441B3BD@fmsmsx120.amr.corp.intel.com I'm thinking it is fine to convert the preempt_disable() just to preempt_disable_nort() (where it's a nop when PREEMPT_RT is enabled). In the mentioned thread, the counters do not seem to be important to the current CPU, just that they get incremented by "some" CPU. Adding back the patch for Mike: The above will only disable preemption when PREEMPT_RT is not enabled. Honestly, if it's just an optimization, and the counters are not that important, do we care on non PREEMPT_RT to disable preemption, and can we just remove the preempt_disable() totally? Depending if it triggers warnings using this_cpu_inc/dec() from preempt enabled regions. -- Steve --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c index 615be68e40b3..3a30bde9a07b 100644 --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c @@ -1421,7 +1421,7 @@ struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len, /* there is enough room */ - preempt_disable(); + preempt_disable_nort(); this_cpu_inc(*sc->buffers_allocated); /* read this once */ diff --git a/drivers/infiniband/hw/hfi1/pio_copy.c b/drivers/infiniband/hw/hfi1/pio_copy.c index 03024cec78dd..c3f48f705c97 100644 --- a/drivers/infiniband/hw/hfi1/pio_copy.c +++ b/drivers/infiniband/hw/hfi1/pio_copy.c @@ -162,7 +162,7 @@ void pio_copy(struct hfi1_devdata *dd, struct pio_buf *pbuf, u64 pbc, /* finished with this buffer */ this_cpu_dec(*pbuf->sc->buffers_allocated); - preempt_enable(); + preempt_enable_nort(); } /* @@ -753,5 +753,5 @@ void seg_pio_copy_end(struct pio_buf *pbuf) /* finished with this buffer */ this_cpu_dec(*pbuf->sc->buffers_allocated); - preempt_enable(); + preempt_enable_nort(); }