Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp482101imm; Tue, 15 May 2018 04:45:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpPSdOYEbzkBQAV+d3xUmH2z+6q2rnW4U5UmGTpKgMtgaoXbEyBZ4WHDc+E1U0e628IUKa8 X-Received: by 2002:a63:955e:: with SMTP id t30-v6mr11696833pgn.77.1526384725104; Tue, 15 May 2018 04:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526384725; cv=none; d=google.com; s=arc-20160816; b=nTw2zOAJPSR9+hT/tP1Qvty5rkfJPWeKOsRRol1n6ogQIHhiNsIjNv77ceaFUP5Jc3 Suc0vlc7MjiUKy31lMIKPVaH/45r0ZCfW51E56QSgEWMnxGN8Uoqdt0GjTszeEQaY4nY sb1Qho0OLOjtl7OSKHm6IDBfHELmiNqxVBpxy4N0cNZMMI/HB3Uolos0UE6mnSJbIuMQ YNDQuRvSLj1++fhBwnkYLdB9UzF6BKkPJzuW/0F/u3tRi6WnjpYgOeSE9wfLwtx1L+C2 lkfIJ7gtcZaPz44iuc+AlmTiNPtCvIgit0oNnmUoSaEDoVD5K0W5uW+f72oW37pPs+XO dLQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=5JPWZewhgzrVO8FqKd9eD0MPwrEiLcPwk24XDzBll7w=; b=oDujpEXK2oc142/7zFvkv8Mw/tJZx5QOi46bEElNelHl+9Lb6ArlhSdLU8sKwxuzq5 kgxsOmvAp6VbtV+4PzNdOfA2uNR2TMjzDWDe+Oh7L8m2LPzM6p6r71sxoTW+g446Q59H 0vvHvRnSWQwOImPHhCXT92+0fusKuPbPKNm5VxnQXg9schMk1zn2SFjohnxIKbz6LWMG gVNHHroewtx4L1tavu4CCDWJvmouZ/ALsFUXuLKFy5qSMjMvJSj+eRvicRxxtJ1HS13R ZZK3/Omruy8rUYud/itvtRanwfKLZiiYI1ZdKJZPrjT3rGrlp8SdfOnY8JfjO9scHZkO pvxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OlUHQB8k; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2-v6si8872332pge.105.2018.05.15.04.45.04; Tue, 15 May 2018 04:45:25 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=OlUHQB8k; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752606AbeEOLlx (ORCPT + 99 others); Tue, 15 May 2018 07:41:53 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45260 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbeEOLlw (ORCPT ); Tue, 15 May 2018 07:41:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5JPWZewhgzrVO8FqKd9eD0MPwrEiLcPwk24XDzBll7w=; b=OlUHQB8kyvjRabM0wWe+nvoiw pCia7a2GxcNiABrNZvJ76J26zS15d99xoXkk/PtHzLeCjsxLlrqjmiDZaMS5erUzL1RA52LQszdld T7rN1tQH2PQnT2Hb61iY+mnJtohGEuddxV9Ye4OhgWDFJ8Avcr/O0Tpk9rKt6jb4pGiIkgpey/Xbt 0AwQeSdBmjETIF4qtFUDQbDDcWD8uQH79BWDDrjwrM+ZrJt1hWD4BodsD+2V5eQBBUWm8Fljrs8FU 8/+Oc4INgi0Fj/BF8cbzZTMP85Nr0irPS+8z2bLyEjOOWa/hUPBSeQ3C7mQKWbgotg15DvD+nljHW o8sbxzIBQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIYKx-0002UD-6R; Tue, 15 May 2018 11:41:47 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E51F12029F1C0; Tue, 15 May 2018 13:41:44 +0200 (CEST) Date: Tue, 15 May 2018 13:41:44 +0200 From: Peter Zijlstra To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, will.deacon@arm.com, mark.rutland@arm.com, torvalds@linux-foundation.org, paulmck@linux.vnet.ibm.com, tglx@linutronix.de, hpa@zytor.com, linux-tip-commits@vger.kernel.org Subject: Re: [tip:locking/core] locking/atomics: Simplify the op definitions in atomic.h some more Message-ID: <20180515114144.GX12217@hirez.programming.kicks-ass.net> References: <20180505083635.622xmcvb42dw5xxh@gmail.com> <20180509073327.GE12217@hirez.programming.kicks-ass.net> <20180515083556.GA30420@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180515083556.GA30420@gmail.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 10:35:56AM +0200, Ingo Molnar wrote: > Which is just _half_ the linecount. It also provides less. I do not believe smaller is better here. The line count really isn't the problem with this stuff. The main pain point here is keeping the atomic, atomic64 and atomic_long crud consistent, typically we tend to forget about atomic_long because that lives in an entirely different header. In any case, see: https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/commit/?h=atomics/generated&id=e54c888b3b9d8f3ef57b1a9c4255a6371cb9977d which generates the atomic/atomic64 bits but does not yet deal with atomic_long (I think I would've kept the 'header' thing in the normal .h file but whatever). Once we have the atomic_long thing added, we should also have enough data to do function forwarding, and we should be able to start looking at the whole annotated stuff. Now clearly Mark hasn't had time to further work on that. But consider a table like: add(i,v) RF sub(i,v) RF inc(v) RF dec(v) RF or(i,v) F and(i,v) F andnot(i,v) F xor(i,v) F xchg(v,i) X cmpxchg(v,i,j) X try_cmpxchg(v,I,j) XB With the following proglet; that should contain enough to do full forwarding (seems I forgot to implement 'B'). --- #!/bin/bash gen_proto() { local cnt=0; proto=$1; shift; ret=$1; shift; pfx=$1; shift; sfx=$1; shift; echo -n "${ret} "; name=${proto%(*}; echo -n "${pfx}${name}${sfx}(" args=${proto#*\(}; for arg in ${args//[,)]/ }; do if [ $cnt -gt 0 ] then echo -n ", "; fi let cnt++; echo -n "${TYPES[$arg]} ${arg}" done echo ");" } gen_proto_order() { gen_proto $1 $2 $3 $4 gen_proto $1 $2 $3 $4_acquire gen_proto $1 $2 $3 $4_release gen_proto $1 $2 $3 $4_relaxed } gen_void_protos() { grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta; do gen_proto ${proto} "void" ${TYPES[pfx]} "" done } gen_return_protos() { grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta; do if [[ $meta =~ "R" ]]; then gen_proto_order ${proto} ${TYPES[i]} ${TYPES[pfx]} "_return" fi done } gen_fetch_protos() { grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta; do if [[ $meta =~ "F" ]]; then gen_proto_order ${proto} ${TYPES[i]} "${TYPES[pfx]}fetch_" "" fi done } gen_exchange_protos() { grep -v -e "^$" -e "^#" atomic.tbl | while read proto meta; do if [[ $meta =~ "X" ]]; then gen_proto_order ${proto} ${TYPES[i]} ${TYPES[pfx]} "" fi done } gen_protos() { gen_void_protos gen_return_protos gen_fetch_protos gen_exchange_protos } declare -A TYPES=( [pfx]="atomic_" [v]="atomic_t *" [i]="int" [j]="int" [I]="int *" ) gen_protos declare -A TYPES=( [pfx]="atomic64_" [v]="atomic64_t *" [i]="s64" [j]="s64" [I]="s64 *" ) gen_protos declare -A TYPES=( [pfx]="atomic_long_" [v]="atomic_long_t *" [i]="long" [j]="long" [I]="long *" ) gen_protos