Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1547491img; Tue, 19 Mar 2019 09:57:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDzcOM39JZv6wkRCkGiHPvaMjE+2pLoX/CN3lZcBdaBadPBmEEijxD9m1cG9dSybI/QD8X X-Received: by 2002:a63:c60c:: with SMTP id w12mr2759621pgg.446.1553014674547; Tue, 19 Mar 2019 09:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553014674; cv=none; d=google.com; s=arc-20160816; b=SV4e6CCwPNfHn7CbePgk+FQvJRIsH7Yv+UhXos8pkK3PNjDfvf8d40XVY08gBdp3TR RznVbY9OTxRfbi+FJKW7wSdXa7OSXXvWsTlWyfpj41SWZA/5WrLmvvPSnaA7ng15d/Hu c1vtwnRbZf+3ESiQ0HDTn5g7GjoaVGHl8oduRr/ZWUvoaEt2ZvrrDku6WBCaOIpQEh04 l+k/nJVwXgz8GQ3/2iZ2wyuBMC0glNXOVUKom0KvvJ3UKITQXPjZnlOgF6Fc4xZuP9Ze Vl+S6fjJ7ENd0BAH+01jDa8ICWHw1ysG0CxtZGbDOFLoaLGcIWMuR3n3extzh3+pf69p 06Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=JbLDn38ENuwUNilFgHlGP9jX7vfJVVtIackWhCzkZUw=; b=xKy331CzsTvzRA29j3v4JjKvCVWtC4kZXjNFVMjdlW5am+tJ5POC8R41xN8cKQOqjo xA7nHRooD3X/pO2l60OilzEjUq4yHNJR/MqK+XY0vtq5DinCc1alTGWWr8DIdLDYFjug ds/Orqpy8qMrvfmcIPzuPPpxfKqRUfqzSpo5IGmyt1s9+p+mvuQdFz14XuRu39GEtNVN vfdhVdT+Y4/o42y6FxeZGGf1AZbr9teODG38OzP+0cRxpyev1bFFJUC3UTy0YnSLg9Ej MCSddARBBxqA/Vkt81oQ95HTYybb0JLpMtO+Zj7Grf/Yuy5hJorWi19ff4b8bKmhf0W/ K+vw== ARC-Authentication-Results: i=1; mx.google.com; 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 f1si11466222pgv.418.2019.03.19.09.57.39; Tue, 19 Mar 2019 09:57:54 -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; 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 S1727087AbfCSQ4w (ORCPT + 99 others); Tue, 19 Mar 2019 12:56:52 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41526 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbfCSQ4w (ORCPT ); Tue, 19 Mar 2019 12:56:52 -0400 Received: by mail-pf1-f195.google.com with SMTP id d25so14105345pfn.8 for ; Tue, 19 Mar 2019 09:56:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=JbLDn38ENuwUNilFgHlGP9jX7vfJVVtIackWhCzkZUw=; b=fQIfUgnH4uzH65ajbnalEQQU3ZEcv+y1i79YuuYSUr7X710Oi/xjRDvj837a+xNuK2 0UpxY9lF7ilg0J22W5mkQEM86XT59gTPWHE5mONO6shHoWFjt8aRzwnXAGJonxIndDxj AFs1lQrDbEx7/wKUAusmjn/UKfgwjVdwj1T/ReKhLs/GmfG/RJbX7ty0TdBuGSg74QSl LKysoAFGmwccyUapvRPMoq2/MjRB6wDiHQMIOVeNa+PyyUlWZQSIV1CVmkSSuynn2UmH JsGrFJ8T3Ewg8Cix3cEN0pR1cBqg2Zt04Tabno4edDB1UiJz2Iq0NwcL7oWGiBEAqX4O IYeQ== X-Gm-Message-State: APjAAAXfccR5MWWfDNWr06ccz+Uhzc0XFx0gf5XeO2Di1oJKJnpcJh7u xLHqjLWNgf/ZTZ9jVZMCr3E= X-Received: by 2002:a17:902:9a02:: with SMTP id v2mr3472941plp.201.1553014611725; Tue, 19 Mar 2019 09:56:51 -0700 (PDT) Received: from ?IPv6:2620:15c:2cd:203:5cdc:422c:7b28:ebb5? ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id t129sm10776016pfb.127.2019.03.19.09.56.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 09:56:51 -0700 (PDT) Message-ID: <1553014609.65329.12.camel@acm.org> Subject: Re: [PATCH v2 16/19] locking/lockdep: Use function pointer to avoid constant checks From: Bart Van Assche To: Yuyang Du , peterz@infradead.org, will.deacon@arm.com, mingo@kernel.org Cc: ming.lei@redhat.com, linux-kernel@vger.kernel.org Date: Tue, 19 Mar 2019 09:56:49 -0700 In-Reply-To: <20190318085733.3143-17-duyuyang@gmail.com> References: <20190318085733.3143-1-duyuyang@gmail.com> <20190318085733.3143-17-duyuyang@gmail.com> Content-Type: text/plain; charset="UTF-7" X-Mailer: Evolution 3.26.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-03-18 at 16:57 +-0800, Yuyang Du wrote: +AD4 +-static inline struct list+AF8-head +ACo-get+AF8-forward+AF8-dep(struct lock+AF8-list +ACo lock) +AD4 +-+AHs +AD4 +- return +ACY-lock-+AD4-class-+AD4-locks+AF8-after+ADs +AD4 +-+AH0 +AD4 +- +AD4 +-static inline struct list+AF8-head +ACo-get+AF8-backward+AF8-dep(struct lock+AF8-list +ACo lock) +AD4 +-+AHs +AD4 +- return +ACY-lock-+AD4-class-+AD4-locks+AF8-before+ADs +AD4 +-+AH0 +AD4 +- +AD4 static int +AF8AXw-bfs(struct lock+AF8-list +ACo-source+AF8-entry, +AD4 void +ACo-data, +AD4 int (+ACo-match)(struct lock+AF8-list +ACo-entry, void +ACo-data), +AD4 struct lock+AF8-list +ACoAKg-target+AF8-entry, +AD4 - int forward) +AD4 +- struct list+AF8-head +ACo(+ACo-get+AF8-dep)(struct lock+AF8-list +ACo lock)) +AD4 +AHs +AD4 struct lock+AF8-list +ACo-entry+ADs +AD4 struct lock+AF8-list +ACo-lock+ADs +AD4 +AEAAQA -1392,11 +-1402,7 +AEAAQA static int +AF8AXw-bfs(struct lock+AF8-list +ACo-source+AF8-entry, +AD4 goto exit+ADs +AD4 +AH0 +AD4 +AD4 - if (forward) +AD4 - head +AD0 +ACY-source+AF8-entry-+AD4-class-+AD4-locks+AF8-after+ADs +AD4 - else +AD4 - head +AD0 +ACY-source+AF8-entry-+AD4-class-+AD4-locks+AF8-before+ADs +AD4 - +AD4 +- head +AD0 get+AF8-dep(source+AF8-entry)+ADs +AD4 if (list+AF8-empty(head)) +AD4 goto exit+ADs +AD4 +AD4 +AEAAQA -1410,10 +-1416,7 +AEAAQA static int +AF8AXw-bfs(struct lock+AF8-list +ACo-source+AF8-entry, +AD4 goto exit+ADs +AD4 +AH0 +AD4 +AD4 - if (forward) +AD4 - head +AD0 +ACY-lock-+AD4-class-+AD4-locks+AF8-after+ADs +AD4 - else +AD4 - head +AD0 +ACY-lock-+AD4-class-+AD4-locks+AF8-before+ADs +AD4 +- head +AD0 get+AF8-dep(lock)+ADs +AD4 +AD4 DEBUG+AF8-LOCKS+AF8-WARN+AF8-ON(+ACE-irqs+AF8-disabled())+ADs +AD4 +AD4 +AEAAQA -1445,7 +-1448,7 +AEAAQA static inline int +AF8AXw-bfs+AF8-forwards(struct lock+AF8-list +ACo-src+AF8-entry, void +ACo-data, +AD4 int (+ACo-match)(struct lock+AF8-list +ACo-entry, void +ACo-data), +AD4 struct lock+AF8-list +ACoAKg-target+AF8-entry) +AD4 +AHs +AD4 - return +AF8AXw-bfs(src+AF8-entry, data, match, target+AF8-entry, 1)+ADs +AD4 +- return +AF8AXw-bfs(src+AF8-entry, data, match, target+AF8-entry, get+AF8-forward+AF8-dep)+ADs +AD4 +AD4 +AH0 +AD4 +AD4 +AEAAQA -1453,7 +-1456,7 +AEAAQA static inline int +AF8AXw-bfs+AF8-backwards(struct lock+AF8-list +ACo-src+AF8-entry, void +ACo-data, +AD4 int (+ACo-match)(struct lock+AF8-list +ACo-entry, void +ACo-data), +AD4 struct lock+AF8-list +ACoAKg-target+AF8-entry) +AD4 +AHs +AD4 - return +AF8AXw-bfs(src+AF8-entry, data, match, target+AF8-entry, 0)+ADs +AD4 +- return +AF8AXw-bfs(src+AF8-entry, data, match, target+AF8-entry, get+AF8-backward+AF8-dep)+ADs +AD4 +AD4 +AH0 I think this patch makes the code harder to read. Additionally, if the compiler doesn't do conditional folding, this patch introduces an indirect branch and hence will make the lockdep code slower. Bart.