Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3614329imu; Tue, 18 Dec 2018 01:03:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/U4Ds46Grf67i7JSTiBk459p9CSa08I6fDodCh2DS5n5tJlvKCqmYCGKOxKOHLQ2gkYB1kF X-Received: by 2002:a63:e655:: with SMTP id p21mr14862068pgj.70.1545123803011; Tue, 18 Dec 2018 01:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545123802; cv=none; d=google.com; s=arc-20160816; b=aMUDRG2eUiE83HK5WXILd9UcFnUTwO31O4niRemThcJt3rj0rnheO7zxJXbHCYCuV7 H9kmaNW9y2niD/KrRTQ1sN05AmGRJKmOV/wmAMebHgvgADPr5zWwfyFnhJJuDYA3kAie W4oeDGeEj6uhqYgOoO8ilFB/Nx/0G0bI8RYyxOZdBy27NLSyppjLj0Hch2ZKOFhE36FT HSj1+P5YL9rKI2cHLQAnJG9sHUdRtF/FUzVTDkdQHglDGrAJ7FDqMfPH8bdSbGN26vgD pKYqccWj/QeBR+RSABS1TpSYKtHA7Whw4wsgeLmEYXnw++ktSvJAQcDZr5yAPFv9vqq2 ddpA== 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=MVgdAr/y+djLEPGEmPkvQPcXziYn3WME/X18BOkf4Nc=; b=fzOAHMQLgfruZVWMWoWEYtP36f7qa0JukHkprxmJxaZF+guo4+mMOhvpvCYd/wGOEt 4nR7xgz3BzGzcO2Q2k4YaMnJZankTXw2V1AXG28TEnA2O1xFRHHQmp0NdAAMXBzz9YkS eEx20Zemp1HSHkZEH7u7CkhAcZBszGqLPUfLj2chFQ6dfes9zohKJPT5HAtp4qNTGtCh fJ7YajVTS04WgvSfc9EdqRtd9Wj0XWqQXZE1hlxPyGWFQR0UGQElKyERJI/zB9gJGX+A HZyfgYxCBFJunPmb7UlDbMQ3Xv/QJHCW86dqUplUzR+zYqBh2cCoww81nRz87j5IjDjE RzSg== 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 cc17si13707989plb.265.2018.12.18.01.03.07; Tue, 18 Dec 2018 01:03:22 -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 S1726479AbeLRJBC (ORCPT + 99 others); Tue, 18 Dec 2018 04:01:02 -0500 Received: from mx2.suse.de ([195.135.220.15]:48180 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726316AbeLRJBC (ORCPT ); Tue, 18 Dec 2018 04:01:02 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D6AC9AE0E; Tue, 18 Dec 2018 09:00:59 +0000 (UTC) Date: Tue, 18 Dec 2018 10:00:59 +0100 (CET) From: Miroslav Benes To: Nicholas Mc Guire cc: Joe Lawrence , Nicholas Mc Guire , Josh Poimboeuf , Jessica Yu , Jiri Kosina , Petr Mladek , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2] livepatch: fix non-static warnings In-Reply-To: <20181217192308.GB26825@osadl.at> Message-ID: References: <1544965657-26804-1-git-send-email-hofrat@osadl.org> <20ef1d3a-2916-ce00-2938-3397746efac9@redhat.com> <20181217192308.GB26825@osadl.at> 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 Mon, 17 Dec 2018, Nicholas Mc Guire wrote: > On Mon, Dec 17, 2018 at 10:44:36AM -0500, Joe Lawrence wrote: > > On 12/17/2018 07:03 AM, Miroslav Benes wrote: > > > Hi, > > > > > > I'm sorry for being late to the party. > > > > > > On Sun, 16 Dec 2018, Nicholas Mc Guire wrote: > > > > > >> Sparse reported warnings about non-static symbols. For the variables > > >> a simple static attribute is fine - for those symbols referenced by > > >> livepatch via klp_func the symbol-names must be unmodified in the > > >> symbol table - to resolve this the __noclone attribute is used > > >> for the shared statically declared functions. > > >> > > >> Signed-off-by: Nicholas Mc Guire > > >> Suggested-by: Joe Lawrence > > >> Link: https://lkml.org/lkml/2018/12/13/827 > > > > > > A nit, but I'd reorder the tags. Link, Suggested-by:, Signed-off-by:. Also > > > it would be great if you used https://lkml.kernel.org/r/${Msg-ID} > > > redirection. > > > > > >> --- > > >> > > >> V2: not all static functions shared need to carry the __noclone > > >> attribute only those that need to be resolved at runtime by > > >> livepatch - so drop the unnecessary __noclone attributes as > > >> well as the Note on __noclone as suggested by Joe Lawrence > > >> - thanks ! > > > > > > I talked to Martin Jambor (GCC) and he suggested __attribute__((used)). It > > > should be better than __noclone, which was reportedly implemented only for > > > testing purposes (which is why it does not imply noinline, although > > > inlining internally uses cloning). Newer gcc also has "noipa" attribute, > > > but "used" would definitely be safe. > > > > > > Sorry for not responding earlier. > > > > > > > Hi Miroslav, > > > > Thanks for following up on this. "noipa" would have been nice to use, > > but as you say, is a newer gcc attribute. > > > > Regarding "used" vs. "noclone", can we assume that "used" implies that > > the function name remains unchanged? > > > > The gcc online doc [1] speaks about ensuring that "code must be > > emitted". This reads like it solves our > > static-function-not-directly-referenced problem, but isn't explicit > > about naming. > > > > used > > > > This attribute, attached to a function, means that code must be > > emitted for the function even if it appears that the function is not > > referenced. This is useful, for example, when the function is > > referenced only in inline assembly. > > > > Perhaps it's equivalent to a "I want to keep this function and leave > > it's symbols alone" attribute. FWIW, I modified Nicholas' change on my > > box to use "used" and it worked as Martin advertised, so it would get my > > Ack. > > > > I'm just being picky about its documentation and how we should note its > > usage in the v3 patch. Think that s/__noclone/used/g of the v2 commit > > message would be sufficient? > > > should that then not be __used as this is provided in compiler_attributes.h > see also: https://lkml.org/lkml/2018/9/20/909 Yes, __used is better. > also would it be reasonable to maybe add something like: > #define __livepatch __attribute__((__noclone__, __noinline__)) > in compiler_attributes.h ? it would make it imediately clear that the attributes > are related to the way lp works internally. No, I don't think so. The samples (and selftests) are special in that we would like to provide minimal examples (or testcases). GCC is in the way due to its optimizations. It is not the case with the common code (the problem there is a bit different. Some optimizations are just dangerous for livepatching. However that is tangential to this patch and will be solved elsewhere). Thanks, Miroslav