Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp226915lqp; Tue, 11 Jun 2024 02:37:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKGcpoerluirUcpr2bJS+Ao7hAonRzy2W5DgsaGBqgX/iGlsscUrexWT4vbxZZMKrKGr7iGsvVqf3veKmTtHHuiTSSzzOx4h082DKxlw== X-Google-Smtp-Source: AGHT+IH8d204rC8kC6q6BEpmYNtPI+/cupHi8XC6ztXc3rRn+iN2ASrJ63u4r3poEfHeN9Np3sm1 X-Received: by 2002:a05:6214:2c0e:b0:6b0:7716:e9a4 with SMTP id 6a1803df08f44-6b07716e9e7mr70828226d6.12.1718098656030; Tue, 11 Jun 2024 02:37:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718098656; cv=pass; d=google.com; s=arc-20160816; b=K9rtwW/2HFJyE+HEg/x9BDpTgyeK6ppqJG4O5t4iIdn9TqUBddYJZgGgK4nrGvP/Dp xmyUCX+DNPy1itnxMAFJZbJ1lOY+s6hdGSCFYJKW20oIDhFkeNdl9/7RY9PGvDe/3bYd Y6OywC4whV1n344DEPaLumGoRjO7Q8i7WIAQHWuo98FfTQHFcXN8GNZZP4n7yDGax0Us 8KzoBqs/vIEvK1c18/0zsnhm/xSLEbQE/PbSpQwIg3nVA8ytbg8UwYRCmotdkFWgifuF U2vqLOYDZHaOy+zKOlAVFYX8j1lglgelhVINGaQw5WURNW6nJh4j3dekMaAosN+O2ETT 9XLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=PfEz3TkLbuHAt4zKlB7WinAu3Bv0qmq8MratQcnTB9o=; fh=Yu5KERqLKzQ3OQERQZvUt/2et8ouZO7koClvm3zNoPs=; b=PDZ6XfKDJ9ifVhLet0e+Kl61XGSaBbP3dN1Wmv//NsktS0UJnHDh0ezvJJnI8wkfuF D/vz/dTAjBxNgsJJfY1VUAafulUDZoQ31pidEBJQKXW8ZALrQhcZvZuaiH1XD75vtuW2 OSnCs+xVBETplacIY1ajPiuRki76cjrm/kCTaofZuoe435BL/FgYwT6rG0ET+IXREoVn G1oJNltzp1W+wcRCHQ7LrrWTske+Xe9YWV71aJo5RFvmc9XOvhMyupkD//n5HHXOzLEF h76z3yxfpJpkLqxQYKaPSHzzZOhqj3ovDlPELiCcueptPfp9sijRbyT0LXHIVGwQ3vYb kOcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-209583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b07a7e3e47si50809026d6.44.2024.06.11.02.37.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 02:37:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-209583-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B13A91C23785 for ; Tue, 11 Jun 2024 09:37:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5C4C17994C; Tue, 11 Jun 2024 09:36:58 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B70C8176FC9; Tue, 11 Jun 2024 09:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098618; cv=none; b=FD9+ClsD4SrEGaPJHzjqoppAcTFCHD69k0wVwKIjtWinPIDFOqSm0Kmo+tym5dcKoZXCGd3SGhJSAvxog0nib1LWmHevjm8iLrhUdMNgdubihGwadDI5gS/E1l6DJYuILZLaEB6CXGdrycWgfGkWWXMzmpeoStn7auUfmNKk9j4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098618; c=relaxed/simple; bh=q+pnA94jVzMSLj4z6FXJf6PzzV6xwk04ttDNDlMYGio=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=qWsFh4p0FHaDEorGk0oAjO1AsNjxqSif4JDsR55N4uaobO5kJ0poAzP5b59lwIEchmAnrjSaIAMaaDlaYeK0uMN2AIXlo1l793RGJ1/+FDAbJNR2L4MHgnq/f3MleRA0+Lfpun1MNyRYUmfxMmkFT2+/afBeAvm/VE9tKZQ/LMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Vz3PT4NTzz3560P; Tue, 11 Jun 2024 17:33:01 +0800 (CST) Received: from dggpeml500012.china.huawei.com (unknown [7.185.36.15]) by mail.maildlp.com (Postfix) with ESMTPS id 161E5180065; Tue, 11 Jun 2024 17:36:48 +0800 (CST) Received: from [10.67.111.172] (10.67.111.172) by dggpeml500012.china.huawei.com (7.185.36.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 11 Jun 2024 17:36:47 +0800 Message-ID: Date: Tue, 11 Jun 2024 17:36:47 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [RFC PATCH] ftrace: Skip __fentry__ location of overridden weak functions Content-Language: en-US To: Peter Zijlstra CC: , , , , , , , , , References: <20240607115211.734845-1-zhengyejian1@huawei.com> <20240607150228.GR8774@noisy.programming.kicks-ass.net> <57e499a4-e26d-148f-317d-233e873d11b4@huawei.com> <20240611092157.GU40213@noisy.programming.kicks-ass.net> From: Zheng Yejian In-Reply-To: <20240611092157.GU40213@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500012.china.huawei.com (7.185.36.15) On 2024/6/11 17:21, Peter Zijlstra wrote: > On Tue, Jun 11, 2024 at 09:56:51AM +0800, Zheng Yejian wrote: >> On 2024/6/7 23:02, Peter Zijlstra wrote: > >>> Oh gawd, sodding weak functions again. >>> >>> I would suggest changing scipts/kallsyms.c to emit readily identifiable >>> symbol names for all the weak junk, eg: >>> >>> __weak_junk_NNNNN >>> >> >> Sorry for the late reply, I just had a long noon holiday :> >> >> scripts/kallsyms.c is compiled and used to handle symbols in vmlinux.o >> or vmlinux.a, see kallsyms_step() in scripts/link-vmlinux.sh, those >> overridden weak symbols has been removed from symbol table of vmlinux.o >> or vmlinux.a. But we can found those symbols from original xx/xx.o file, >> for example, the weak free_initmem() in in init/main.c is overridden, >> its symbol is not in vmlinx but is still in init/main.o . >> >> How about traversing all origin xx/xx.o and finding all weak junk symbols ? > > You don't need to. ELF symbl tables have an entry size for FUNC type > objects, this means that you can readily find holes in the text and fill > them with a symbol. > > Specifically, you can check the mcount locations against the symbol > table and for every one that falls in a hole, generate a new junk > symbol. > > Also see 4adb23686795 where objtool adds these holes to the > ignore/unreachable code check. > > > The lack of size for kallsyms is in a large part what is causing the > problems. Thanks for your suggestions, I'll try it soon. -- Thanks, ZYJ