Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17A98C7EE30 for ; Wed, 1 Mar 2023 19:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjCAToC (ORCPT ); Wed, 1 Mar 2023 14:44:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjCAToA (ORCPT ); Wed, 1 Mar 2023 14:44:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C3572FCFE; Wed, 1 Mar 2023 11:43:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1ED53614B3; Wed, 1 Mar 2023 19:43:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 648FEC433D2; Wed, 1 Mar 2023 19:43:57 +0000 (UTC) Date: Wed, 1 Mar 2023 14:43:55 -0500 From: Steven Rostedt To: Uros Bizjak Cc: Joel Fernandes , "Paul E. McKenney" , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan Subject: Re: [PATCH] rcu: use try_cmpxchg in check_cpu_stall Message-ID: <20230301144355.338c62de@gandalf.local.home> In-Reply-To: References: <20230228155121.3416-1-ubizjak@gmail.com> <20230228160324.2a7c1012@gandalf.local.home> <20230228212911.GX2948950@paulmck-ThinkPad-P17-Gen-1> <20230228164124.77c126d2@gandalf.local.home> <20230228190846.79b06089@gandalf.local.home> <20230301113813.4f16a689@gandalf.local.home> <20230301135201.59771b73@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 Mar 2023 20:18:11 +0100 Uros Bizjak wrote: > If we want to put the definition in generic headers, then we also need > to define acquire/release/relaxed and 64bit variants. ATM, we have two > sites that require this definition and I think that for now we could > live with two instances of the same definition in two separate > subsystems. But this would definitely be a good future addition. There > is some code in the form of > > if (cmpxchg (ptr, 0, 1) == 0) > > that can not be converted to try_cmpxchg, but can use cmpxchg_success. And even modify code that uses temp variables. For example, where you modified the ring buffer code to use try_cmpxchg(), I could convert your: static int rb_head_page_replace(struct buffer_page *old, struct buffer_page *new) { unsigned long *ptr = (unsigned long *)&old->list.prev->next; unsigned long val; val = *ptr & ~RB_FLAG_MASK; val |= RB_PAGE_HEAD; return try_cmpxchg(ptr, &val, (unsigned long)&new->list); } Into just: static int rb_head_page_replace(struct buffer_page *old, struct buffer_page *new) { unsigned long *ptr = (unsigned long *)&old->list.prev->next; unsigned long val; val = *ptr & ~RB_FLAG_MASK; return cmpxchg_success(ptr, val | RB_PAGE_HEAD, (unsigned long)&new->list); } -- Steve