Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp64671ybp; Thu, 3 Oct 2019 10:13:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1/Zh+MNPtN/tjnnwoILZGHG4r6+lRj19oa4Iu6IPcuIjiC23n3AVLBnttcwPJtkTGLhRE X-Received: by 2002:a17:906:1c5b:: with SMTP id l27mr8745989ejg.27.1570122822464; Thu, 03 Oct 2019 10:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122822; cv=none; d=google.com; s=arc-20160816; b=eqdE5HII5PXDbtL0zmuv41WDS2gqDwOCeM0Me5Mji70pNdotITnsqV6vouA52Yfp75 YKM7U96Addf1A5qj/1Cayas3thhdS5Y8qO3iOJ0pUJLMDR6U9WALLARhNogxO5sQDPpE iVjLSn4S5UPee8KqEloOLgWOjGm6EQOFdd9qrsaEAc3YKsF/Rsc1XrgHL0/qAEoFNJ8e u1ic+AcDcpVXwIw/lCAAUsNtzo48Ykn7rsKwW5VT4pNb6bGyIqrixKFJmFcscQFqxNLM 6qDIljaMv2uArKWtUynjG5N7Q6/9eDe8c0Zb/rGMwtkdse5JwpfYbAVfnW/M/6+Xn2y8 uaPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=Xa4tdzxQuYNj6KgrYhA4aLJ8ZuVzRaG5b/3vwfcSUKY=; b=mEfjdmwOqwm9V1njJ+AHVG2oFrZL/kONWX0Z4dN0hkdZwlhQMsRrLHCg/s3wez+nkw wYI5EpgOrB5zuP0b+y/0MvZVopqlq4Sfup7Dq6cAcCyedJuCBqgsHmuTc2hfSfr4cEIv H+VVUMjF3aTuWS7J7A24hIoIGSWriR5sFShRTe7dUI087UU446tMhNt31WctqcfDWByR oUVtGwlQAzv0PMPh9mshDELvrlYFseMe5FVePMHUWrn8aVNnjsCLUPDugckzbew8pxJ8 8CjttenNAKDQOmSa2n1p8WmAibC69qHdS908WfDIU97hu1kCXQSObBmdf2Cym8yYYYOD ksKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=HRz2dE0k; 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=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si1621518ejx.372.2019.10.03.10.13.17; Thu, 03 Oct 2019 10:13:42 -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=@efficios.com header.s=default header.b=HRz2dE0k; 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=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403915AbfJCQbv (ORCPT + 99 others); Thu, 3 Oct 2019 12:31:51 -0400 Received: from mail.efficios.com ([167.114.142.138]:40570 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403884AbfJCQbk (ORCPT ); Thu, 3 Oct 2019 12:31:40 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 0E47B33ACF0; Thu, 3 Oct 2019 12:31:39 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id ZMVYT95oWAXT; Thu, 3 Oct 2019 12:31:38 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 84E1733ACED; Thu, 3 Oct 2019 12:31:38 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 84E1733ACED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1570120298; bh=Xa4tdzxQuYNj6KgrYhA4aLJ8ZuVzRaG5b/3vwfcSUKY=; h=Date:From:To:Message-ID:MIME-Version; b=HRz2dE0k19vaOBDAn9NaI8MfJQ8pY9RF4PTVC0Xlwep0nYLWyNHK+05Ai1OXf0VXG T6E84w097FHLOUm8iPHe57pX8N8ziTZmZVlLQIMk/89aaVHBxIauDQtVPJMN32vrnG bh5gIT4Uh2ARfLkGH1BB7nBq/u3pSN9j6LPr4AXnzPI/Ow5WGtnRrrz0i6mw91dfhx L3o5WtRhJNkGZSkalrE27yydwfyShXQlC6+6JfD/uXinC3LnaHytIYEt4oxxmSqjh1 U01Pu9I7Ex8pyxwoDBDM6S7CResfW/fzBn58MPRSdnss2s0WTyJpkHjrRDSt1YtZYt ZLq5hKlLD6Sqg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id 9g9rzWrEvl57; Thu, 3 Oct 2019 12:31:38 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 611F333ACD2; Thu, 3 Oct 2019 12:31:38 -0400 (EDT) Date: Thu, 3 Oct 2019 12:31:38 -0400 (EDT) From: Mathieu Desnoyers To: rostedt Cc: David Howells , paulmck@kernel.org, rcu , linux-kernel , Ingo Molnar , Lai Jiangshan , dipankar , Andrew Morton , Josh Triplett , Thomas Gleixner , Peter Zijlstra , Eric Dumazet , fweisbec , Oleg Nesterov , "Joel Fernandes, Google" , Bart Van Assche , Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn , Shane M Seymour , "Martin K . Petersen" Message-ID: <561448323.948.1570120298211.JavaMail.zimbra@efficios.com> In-Reply-To: <20191003090850.1e2561b3@gandalf.local.home> References: <20191003014310.13262-1-paulmck@kernel.org> <20191003014153.GA13156@paulmck-ThinkPad-P72> <25408.1570091957@warthog.procyon.org.uk> <20191003090850.1e2561b3@gandalf.local.home> Subject: Re: [PATCH tip/core/rcu 1/9] rcu: Upgrade rcu_swap_protected() to rcu_replace() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.15_GA_3847 (ZimbraWebClient - FF69 (Linux)/8.8.15_GA_3847) Thread-Topic: Upgrade rcu_swap_protected() to rcu_replace() Thread-Index: V+Isuv29ciiT7lw1a+SgtJRKwn+KMg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Oct 3, 2019, at 9:08 AM, rostedt rostedt@goodmis.org wrote: > On Thu, 03 Oct 2019 09:39:17 +0100 > David Howells wrote: > >> paulmck@kernel.org wrote: >> >> > +#define rcu_replace(rcu_ptr, ptr, c) \ >> > +({ \ >> > + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ >> > + rcu_assign_pointer((rcu_ptr), (ptr)); \ >> > + __tmp; \ >> > +}) >> >> Does it make sense to actually use xchg() if that's supported by the arch? >> > > Hmm, is there really any arch that doesn't support xchg()? It would be > very hard to do any kind of atomic operations without it. > > cmpxchg() is the one that I understand is optional by the arch. I remember going through all kernel arch headers myself and introduce irq-off-based xchg and cmpxchg generic implementations for all UP architectures lacking cmpxchg/xchg instructions. We might want to consider simply using xchg() here. FWIW, the API exposed by the Userspace RCU project (liburcu) for this is: rcu_xchg_pointer() Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com