Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1996577imu; Wed, 21 Nov 2018 05:18:26 -0800 (PST) X-Google-Smtp-Source: AJdET5cTqye3Htryrz7vAJ4i9IDtqNeFufRdDhxDUcEeH7/DTogGdrs/pgzUYX/aZxnX0zPlffKe X-Received: by 2002:aa7:8552:: with SMTP id y18mr6897822pfn.83.1542806306560; Wed, 21 Nov 2018 05:18:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542806306; cv=none; d=google.com; s=arc-20160816; b=jg0Ijtc3SvIRXIGwDKvcIFkm3OQcqRJkxeuUMiBjyOemj8zSKzRZJgNjAJZx9d/QW0 rKsewLqCzvr+Juv8wGa/L1YndC4lP2kJI6lLFhnXZdlY/RTpgn+R+fxeB7GN4qXnVoZq kM/i+HRYz/nOeGZ7g7IKf1WU+Ys7nCPcHU7yPoJaLR1Pgj/dvOvAqeQTFvnzg1elksp9 SEdsd+pamimJSq1gFajuOqdDTcwbBwdvVeAiRl/s9Sl+lwmcQVycgDqFOyaedrc21SL3 2WTI3WtMrzlrDWriPYYYYyZS0X9/+D3pImByxvi/GTy+/i8NTCsDeAWPqhCr6bx+E7ZD TCog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=m9w6Qh651XKQuOiUqQwQuq4rfQEttESnlsqg5yrGZPI=; b=cmntqTHZmO0PLFVR4ml/HskGCUD+fSNxJcmmeFNA7F4d8UCz6gGVK/A7yRl0NTdAH/ iSyT++bX5R2Sl2RYvXpoReegMz0bVWKbXCXlfSBe+UbgwFrFjVABJ8SWPp6sCgdDS/0z rStacUtvXC3cI3dJWXcdVWo9gGlPma+2wQ2HdKPu1KLCrTrlN9+2iVYX0Wd3HHGHKtof A3ddWuL8mROM7fZdYBu9IAUpclE8kP8AF4AXZ5ECtOEfx0i5CfBd+j86fAJafjTQHHOh GYFmqvANfSyDhoggJgUmcpqhqs4m6k7o32V1+sWpPqzTj69G8zaqIHzx6kSsGtWJvxkL eVgw== 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 p12si36835940pli.239.2018.11.21.05.18.10; Wed, 21 Nov 2018 05:18:26 -0800 (PST) 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 S1730137AbeKUWwE (ORCPT + 99 others); Wed, 21 Nov 2018 17:52:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:47400 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727094AbeKUWwD (ORCPT ); Wed, 21 Nov 2018 17:52:03 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CEFD7ADED; Wed, 21 Nov 2018 12:17:52 +0000 (UTC) Date: Wed, 21 Nov 2018 13:17:51 +0100 (CET) From: Miroslav Benes To: Petr Mladek cc: Josh Poimboeuf , Jiri Kosina , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v13 02/12] livepatch: Helper macros to define livepatch structures In-Reply-To: <20181024112822.tam6bal3hnrrgj5m@pathway.suse.cz> Message-ID: References: <20181015123713.25868-1-pmladek@suse.com> <20181015123713.25868-3-pmladek@suse.com> <20181017181756.cy65ujygmf3ulmiz@treble> <20181018111153.qcmvidttifi57u45@pathway.suse.cz> <20181018125824.ms5zovmsnikv3bgt@treble> <20181024112822.tam6bal3hnrrgj5m@pathway.suse.cz> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 24 Oct 2018, Petr Mladek wrote: > On Thu 2018-10-18 07:58:24, Josh Poimboeuf wrote: > > On Thu, Oct 18, 2018 at 01:11:53PM +0200, Petr Mladek wrote: > > > On Wed 2018-10-17 13:17:56, Josh Poimboeuf wrote: > > > > On Mon, Oct 15, 2018 at 02:37:03PM +0200, Petr Mladek wrote: > > > > > The definition of struct klp_func might be a bit confusing. > > > > > The original function is defined by name as a string. > > > > > The new function is defined by name as a function pointer > > > > > casted to unsigned long. > > > > > > > > > > This patch adds helper macros that hide the different types. > > > > > The functions are defined just by the name. For example: > > > > > > > > On one hand, these macros are kind of nice, because they do the function > > > > pointer casting for the user. > > > > > > > > On the other hand, they hide the field names, which hurts readability a > > > > bit. For example, it would be easy to accidentally assign the wrong > > > > callback function. > > > > > > I am not a big fan of the macros either. > > > > > > > > > > Also, it's unfortunate that these macros are needed in the first place. > > > > > > > > What if we just change new_addr (and old_addr) to be 'void *'? Then the > > > > macros wouldn't be as useful, and we could just get rid of them. > > > > > > Hmm, I wonder if any change make sense then. The above proposal might > > > just exchange one confusion with another one: > > > > > > + I would expect that a variable called addr is of the type > > > unsigned long > > > > > > + we would need casting when calling ftrace API > > > > > > + .new_addr = function_xxx looks a bit weird and it will > > > be used many times in all livepatch sources. > > > > Fair points. Instead of changing new_func to new_addr, how about we > > leave it alone, and instead change 'unsigned long old_addr' to 'void > > *old_func'? > > > > That would give us consistent naming internally, while making the > > external interface more sensible and cast-free. > > > > We'd still have to cast when passing to the ftrace API, but IMO it would > > be worth it. > > I am fine with this. I will do this in v14 unless anyone complains ;-) I agree. I don't like the change from 1/12 much as it exposes casting to user. Macros introduced here do not make any better and I go along with Josh. Miroslav