Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5208792imm; Fri, 18 May 2018 19:43:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrPTh28HcDcwNTCTXF6JfYaRMrwPsuUKSI2OtYh0XRdVZ3ItUmhaX4+ueKcsZudynBgDFjr X-Received: by 2002:a17:902:9a08:: with SMTP id v8-v6mr11894365plp.148.1526697786712; Fri, 18 May 2018 19:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526697786; cv=none; d=google.com; s=arc-20160816; b=QVS1ko4q5ma5D4tLvRVwCUOjZCSiRQ7QNWFRvRPN+RNG4i0dDwX4IVaUiblQFppyWT nfWu6uaYOhbsFH26U2QOi+Oc+iyB/nVIlB+L3kWA33DVqEluXHn/qCzzuUs/cSkyPiKh MuiFaxEdT5221L0X4QWefefF41m21YYpBcEH/qPyrPpgsSpH8cyc80ZWqsNqQm1C1nNR wA47C3VSUSHXLrarNOrCAPieRgIW+VNaU3hI4nbaVFsbUKm+hxE8Ahxwq1ycA63CHed1 G7c0KCbZkX9mdMu/xZJncfKZulpECZjxGL8qd8qW1rIb+tswxNgqWE3+dEkdjfGMWAum Hl8g== 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=cX6cTD56ksUZdsUpCxYw4y50Pavv4xlLPkY+2l1SIy4=; b=cDMCB8wLu/AFsIY/0TRir35Se3VEocQD65no1gc7U44c5ZmK8mKyd2Qyv+yPsrj+Kg GZ+4ZXPuEyh+HRHIf4ATJT10qg41T8ZnQZW+A/tf0T0SEzgyau/KDTHEnI58ABSs4Iad ACModwpZVqGecvAVUKDji4YQ3ftyYvSOqS6pBQDcBzg9SVDs4SgsLYivqeCme4C3qvas 9ks3NUY1VlmDMMTlrIEUcySK1asXQYY5XJgq84p/QzqKxLfK2Vvqg3lQecrUMAoFXbyD 4Qo9XzEw41B5efAmWDolx4W8bhdZaN/rBEICm8xtqsXSRYQaxcXAtK1m6297sDzu6MlC /rAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EEj+nKxq; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u138-v6si4370984pgb.136.2018.05.18.19.42.50; Fri, 18 May 2018 19:43:06 -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=@kernel.org header.s=default header.b=EEj+nKxq; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752129AbeESCmm (ORCPT + 99 others); Fri, 18 May 2018 22:42:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:43850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbeESCmk (ORCPT ); Fri, 18 May 2018 22:42:40 -0400 Received: from localhost (LFbn-NCY-1-193-82.w83-194.abo.wanadoo.fr [83.194.41.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BCC1A206B7; Sat, 19 May 2018 02:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526697760; bh=9i1uu+kI+fVQw/emfR3yu3ehx5kGVojcyhbRM0D0KyQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EEj+nKxqbLtyiFr29cjlHpajrAdwJerSDYvPiQbdqrOzeZI1YTg83yLKdUjS/bHKm iZWPttw73YHkkW9h7YtFaYl430JPbxsj+FLuWjQOD4rFD7ZupCb4nKYeNh50rBS/pu Hk1wQxzV5d0nK+CyYnOUv9kW+0vE9m67QGjYDtpE= Date: Sat, 19 May 2018 04:42:37 +0200 From: Frederic Weisbecker To: Andy Lutomirski Cc: Peter Zijlstra , LKML , Jiri Olsa , Namhyung Kim , Linus Torvalds , Yoshinori Sato , Benjamin Herrenschmidt , Catalin Marinas , Chris Zankel , Paul Mackerras , Thomas Gleixner , Will Deacon , Michael Ellerman , Rich Felker , Ingo Molnar , Mark Rutland , Alexander Shishkin , Andy Lutomirski , Arnaldo Carvalho de Melo , Max Filippov Subject: Re: [PATCH 8/9] perf/breakpoint: Split breakpoint "check" and "commit" Message-ID: <20180519024236.GA4260@lerouge> References: <1525634395-23380-1-git-send-email-frederic@kernel.org> <1525634395-23380-9-git-send-email-frederic@kernel.org> <20180509091703.GH12217@hirez.programming.kicks-ass.net> <20180516031059.GA2271@lerouge> <99DA1A94-6AF6-4B9A-858A-7018D58CC38E@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99DA1A94-6AF6-4B9A-858A-7018D58CC38E@amacapital.net> User-Agent: Mutt/1.5.24 (2015-08-30) 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 09:58:03PM -0700, Andy Lutomirski wrote: > > > > On May 15, 2018, at 8:11 PM, Frederic Weisbecker wrote: > > > >> On Wed, May 09, 2018 at 11:17:03AM +0200, Peter Zijlstra wrote: > >>> On Sun, May 06, 2018 at 09:19:54PM +0200, Frederic Weisbecker wrote: > >>> arch/arm/include/asm/hw_breakpoint.h | 5 ++++- > >>> arch/arm/kernel/hw_breakpoint.c | 22 +++------------------- > >>> arch/arm64/include/asm/hw_breakpoint.h | 5 ++++- > >>> arch/arm64/kernel/hw_breakpoint.c | 22 +++------------------- > >>> arch/powerpc/include/asm/hw_breakpoint.h | 5 ++++- > >>> arch/powerpc/kernel/hw_breakpoint.c | 22 +++------------------- > >>> arch/sh/include/asm/hw_breakpoint.h | 5 ++++- > >>> arch/sh/kernel/hw_breakpoint.c | 22 +++------------------- > >>> arch/x86/include/asm/hw_breakpoint.h | 5 ++++- > >>> arch/x86/kernel/hw_breakpoint.c | 23 +++-------------------- > >>> arch/xtensa/include/asm/hw_breakpoint.h | 5 ++++- > >>> arch/xtensa/kernel/hw_breakpoint.c | 22 +++------------------- > >> > >> Because of those ^, > >> > >>> kernel/events/hw_breakpoint.c | 11 ++++++----- > >> > >> would it not make sense to have a prelimenary patch doing something > >> like: > >> > >> __weak int hw_breakpoint_arch_check(struct perf_event *bp) > >> { > >> return arch_validate_hwbkpt_settings(bp); > >> } > > > > So eventually I fear I can't do that, due to linking order. > > > > Say I convert x86 to implement hw_breakpoint_arch_check(), so I > > remove arch_validate_hwbkpt_settings(). On build time, the weak version > > is still compiled and can't find a declaration for arch_validate_hwbkpt_settings(). > > > > I tried to keep the declaration while the definition has been removed but > > it seems the weak version is linked first before it gets later replaced by > > the overriden arch version. So I get a build error. > > > > I could keep arch_validate_hwbkpt_settings() around on all archs and remove it in > > the end with the weak version but that would defeat the purpose of removing > > the mid-state in the current patch. > > How about just not using weak functions? Weak functions have annoying issues like this, and they have trouble generating good code. I much prefer the pattern: > > in arch header: > extern void arch_func(whatever); > #define arch_func arch_func > > in generic header: > #ifndef arch_func > static inline void arch_func(whatever) ... > #endif Thanks, that works well!