Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp383264pxb; Wed, 20 Jan 2021 09:12:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzv7ouaGtiSb6gY+fhHSYGcPd+gOm8HiLcaMu0KAD4TE3SSWW8kbBOtsfhdeS/0q5HkOlSe X-Received: by 2002:a17:906:934c:: with SMTP id p12mr6606263ejw.269.1611162765189; Wed, 20 Jan 2021 09:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611162765; cv=none; d=google.com; s=arc-20160816; b=Z9FKdWMfAXfzXOAOBbhcSET6yJ7ml3a5iwNSNVv0H6LsRpcGrfQ5WhxkbmTKx/8O4l MdtzUBxRdsazAX977yTUfjBsT2cbgFdhFw9SO51wDXsIV4lZJ35asaO0BTrn5oLdfC9R LmGEYsbosv2ffE7PJcn2REVKlroKWvMRe6lq4eyxhGSanQQiCObZnHaQRiSm07buxxjD z5oq0vhXJ8cYe46bQtACdANcMl2Ultg+qxE/VX7+oJqwmvd/9HwcEt3kyRXb8FNHedcU bEPDhBVRitUFEZRZ/Rzfho5YsINGDqK0Eujmj2gAAgHT+Jlrzljtahspx82nJYWoi7me Ckjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:date:message-id:from:references:cc:to :subject:dkim-signature; bh=Y3eJ+LbSttmlYz4ZO1ee7ygVAqStsaWU4Vmqu3XmfNg=; b=g/cyoqf7kZYDxiO97NrBdZin5GgkhvNyVsUuaeD1maOJ9bs4Z/uqgxmtjk5XgPayq+ +FL7gFMs1qrvVMxoLp4QxpLsukWyiY5M9G+Lq0/+rFZnWCdkBA+xu1sD1ORXb4JWQ/0n ifuNiiYYI44BPKbJ7xtMfMryajRDfThcsnjehPSflT7Mh3MnTtJV7l3FMQekyaE8KSbZ R0GOVxwF8+XaxfGT320N/Cf4cRWSZSuRdntqkIGvup90/qXw9F02Vo8PC9qrqQQDKt+q 9eygpnhA/yqPOuPZlLtlQXSjBaVO26027xyjBw41uVQUaD4jcbjPHqtBri187zDbhxfP ONrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AhmkSBXj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si1026727edm.144.2021.01.20.09.12.17; Wed, 20 Jan 2021 09:12:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AhmkSBXj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403913AbhATRKc (ORCPT + 99 others); Wed, 20 Jan 2021 12:10:32 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18512 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391721AbhATRF7 (ORCPT ); Wed, 20 Jan 2021 12:05:59 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10KH3chO166879; Wed, 20 Jan 2021 12:04:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=Y3eJ+LbSttmlYz4ZO1ee7ygVAqStsaWU4Vmqu3XmfNg=; b=AhmkSBXjM3YRWEGnGRUaD5RDO6Vouw8SqbD7xaXFONjqmxfjFwlAMpPjj961BJ1QVy99 PRWi/wxm08PH4lzN4bwxwETm+y2830IuRaPqPvJNc3+xrw4u8tO8973upN+clClAM1CI HeExxB+aasd/Swrr1d+ICpmHyT04RucypFaNd1Jw2dLWmTuAx/arHodzcXfsGkkj+7xj g7KeRyG9WmFZMPeZ/uSlHgRGgacRmiA452KDXJnfP1AAWEL6bFUsf2XkiCLZGhGs5Jgt 2Q3RMtWI/W3EOa3i7A1cvhWIg25JHo5g1NYV0ADSiHkygY0GYtQ/FsbRt2F3QGHzfnhA bw== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 366qewt418-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Jan 2021 12:04:48 -0500 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 10KGwLQn028348; Wed, 20 Jan 2021 17:04:28 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma01fra.de.ibm.com with ESMTP id 3668p4geja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Jan 2021 17:04:28 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 10KH4QJe42467682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 17:04:26 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ECC51AE051; Wed, 20 Jan 2021 17:04:25 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9EB4EAE04D; Wed, 20 Jan 2021 17:04:25 +0000 (GMT) Received: from [9.145.21.215] (unknown [9.145.21.215]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Jan 2021 17:04:25 +0000 (GMT) Subject: Re: [PATCH v2] init/gcov: allow CONFIG_CONSTRUCTORS on UML to fix module gcov To: Johannes Berg , Andrew Morton Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Jessica Yu , Johannes Berg , linux-um@lists.infradead.org References: <20210120172041.c246a2cac2fb.I1358f584b76f1898373adfed77f4462c8705b736@changeid> From: Peter Oberparleiter Message-ID: Date: Wed, 20 Jan 2021 18:04:25 +0100 MIME-Version: 1.0 In-Reply-To: <20210120172041.c246a2cac2fb.I1358f584b76f1898373adfed77f4462c8705b736@changeid> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-20_10:2021-01-20,2021-01-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 malwarescore=0 adultscore=0 impostorscore=0 bulkscore=0 mlxscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200098 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.01.2021 17:20, Johannes Berg wrote: > From: Johannes Berg > > On ARCH=um, loading a module doesn't result in its constructors > getting called, which breaks module gcov since the debugfs files > are never registered. On the other hand, in-kernel constructors > have already been called by the dynamic linker, so we can't call > them again. > > Get out of this conundrum by allowing CONFIG_CONSTRUCTORS to be > selected, but avoiding the in-kernel constructor calls. > > Also remove the "if !UML" from GCOV selecting CONSTRUCTORS now, > since we really do want CONSTRUCTORS, just not kernel binary > ones. > > Signed-off-by: Johannes Berg Looks good+nicer than v1 to me! I also tested this patch on s390 and can confirm that it doesn't break gcov-kernel there. Reviewed-by: Peter Oberparleiter Andrew, do we need additional reviews/sign-offs? Could this go in via your tree? > --- > Tested with a kernel configured with CONFIG_GCOV_KERNEL, without > the patch nothing ever appears in /sys/kernel/debug/gcov/ (apart > from the reset file), and with it we get the files and they work. Just to be sure: could you confirm that this test statement for UML also applies to v2, i.e. that it fixes the original problem you were seeing? > > v2: > * special-case UML instead of splitting the CONSTRUCTORS config > --- > init/Kconfig | 1 - > init/main.c | 8 +++++++- > kernel/gcov/Kconfig | 2 +- > 3 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/init/Kconfig b/init/Kconfig > index b77c60f8b963..29ad68325028 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -76,7 +76,6 @@ config CC_HAS_ASM_INLINE > > config CONSTRUCTORS > bool > - depends on !UML > > config IRQ_WORK > bool > diff --git a/init/main.c b/init/main.c > index c68d784376ca..a626e78dbf06 100644 > --- a/init/main.c > +++ b/init/main.c > @@ -1066,7 +1066,13 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) > /* Call all constructor functions linked into the kernel. */ > static void __init do_ctors(void) > { > -#ifdef CONFIG_CONSTRUCTORS > +/* > + * For UML, the constructors have already been called by the > + * normal setup code as it's just a normal ELF binary, so we > + * cannot do it again - but we do need CONFIG_CONSTRUCTORS > + * even on UML for modules. > + */ > +#if defined(CONFIG_CONSTRUCTORS) && !defined(CONFIG_UML) > ctor_fn_t *fn = (ctor_fn_t *) __ctors_start; > > for (; fn < (ctor_fn_t *) __ctors_end; fn++) > diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig > index 3110c77230c7..f62de2dea8a3 100644 > --- a/kernel/gcov/Kconfig > +++ b/kernel/gcov/Kconfig > @@ -4,7 +4,7 @@ menu "GCOV-based kernel profiling" > config GCOV_KERNEL > bool "Enable gcov-based kernel profiling" > depends on DEBUG_FS > - select CONSTRUCTORS if !UML > + select CONSTRUCTORS > default n > help > This option enables gcov-based code profiling (e.g. for code coverage > -- Peter Oberparleiter Linux on Z Development - IBM Germany