Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2938038pxb; Fri, 8 Oct 2021 19:58:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYYsqjmikUCrWgvzPvAK4bV3hUW8jYjCfFCApNyItPx0pRrYcuCbTdmrjGU/S4mh/2yEkN X-Received: by 2002:a17:906:3891:: with SMTP id q17mr8907248ejd.220.1633748308197; Fri, 08 Oct 2021 19:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633748308; cv=none; d=google.com; s=arc-20160816; b=uohl+vNp9Bw1+lieBVCNkRWOACodSKoTFX7jMhtjwg51BsR6j9JtaczpRNKK3THsXo TMdkdbjnoEwP/tKZmJEaEd/hziYD6K50M/+aONPDb9/Van1bNWmpd4RrEyo20+ghCKgW TS3zkD+2FAiCsMdUkQ2TNB2s1xfGm9Cy82mrtF0rtCAe+1FFrEoQsSMjmrBjbNjE8sRw qnt8Zbzy2KtJjzsDi0pN8+35jU9YjwWd7LJMxy2ntNjBq+BDvATQedm3WXlakVTLF0Ke oA/DmrpjR08mHzLgCndhh3ZzQXh8B6SpUP51cp/3uwSgzAE98LiimstwZzar0RlHMubL joHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=Hkm4A1o+0TX7rVcG0chIpOn+AZXIOo/T5yUtLA5JBEc=; b=I/eHwpxhA3iU0LVV5N3JbvFoLmfGTt7gvgcBUjsL+auVEKrz/2SL1Jrk7AU/nlmj8P A5AomFz9awTX2vqHo0KMQgcLsEDc3zqx4Kgvp6z7hYNziudND+i+1T2cUCLPqrUKBn0Q KDotqdOhREGwAOmZicfLK5/41te8bYMCGrklg6zvR1NqKQyY1sBxadMoYgheud3PPZ0/ GoGtMAcsF/yDnmmb9gB18M4mts+RCITZKRJzxC0402zVDNBC9xwHmerVLKd8qRa7qgTB NPPndp45oDwC6cZ9jafML6Ol4hQs7nfYJbrEaNbS3c0NC1Ib4zlkZ6Vz3QFqCRAcVFVF T7qQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si1343755edl.466.2021.10.08.19.58.03; Fri, 08 Oct 2021 19:58:28 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232207AbhJIC6k (ORCPT + 99 others); Fri, 8 Oct 2021 22:58:40 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:44953 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232081AbhJIC6k (ORCPT ); Fri, 8 Oct 2021 22:58:40 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=yinan@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Ur3IQOD_1633748201; Received: from 30.240.97.92(mailfrom:yinan@linux.alibaba.com fp:SMTPD_---0Ur3IQOD_1633748201) by smtp.aliyun-inc.com(127.0.0.1); Sat, 09 Oct 2021 10:56:42 +0800 Message-ID: <1d069626-1aed-6244-b932-7853e832eb70@linux.alibaba.com> Date: Sat, 9 Oct 2021 10:56:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Subject: Re: [PATCH 1/2] scripts: ftrace - move the sort-processing in ftrace_init to compile time To: Steven Rostedt Cc: mark-pk.tsai@mediatek.com, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org References: <20210911135043.16014-1-yinan@linux.alibaba.com> <20210911135043.16014-2-yinan@linux.alibaba.com> <20210911095937.5a298619@rorschach.local.home> <0b783c9e-c129-6907-0637-5c7638158a65@linux.alibaba.com> <20211008194821.3b6a18a4@oasis.local.home> From: Yinan Liu In-Reply-To: <20211008194821.3b6a18a4@oasis.local.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/10/9 上午7:48, Steven Rostedt wrote: > On Sun, 3 Oct 2021 21:42:10 +0800 > Yinan Liu wrote: > >> Sorry for my slow progress . I have encountered some problems with the >> sorting >> of the module's mcount in compile time. The .ko file will be relocated >> after insmod >> or modprobe, most of the mcount relocation is based on .text section, >> but there are >> also a small part of mcount relocation based on .init.text section such >> as module_init(). >> The loading position of .init.text and .text does not seem to be in a >> definite order. > > Right, there's no guarantee that the .text portion of a module is > placed before or after the .init.text portion. yes. > >> >> For example, when I insmod ip_tables.ko twice, the front and back >> positions of init.text >> and .text are different, so we cannot sort the mcounts in the two >> sections, which makes >> the mcount sorting in the module meaningless. >> >> What is your opinion on this? > > Probably just keep the sorting algorithm in the kernel and take place > on module load. > > If you still want to sort at compile time, then do the sort for .init > functions separate from the .text ones, and have a way to extract this > information (shouldn't be too hard) in the kernel at module load, and > then just swap the init and text functions if they were added in the > reverse order that was expect. > > The functions in .init will either be before all the functions in .text > or after. They wont be intermingled. Thus, if they are both sorted, > then they are placed correctly or the two groups of functions need to > be switched. No other sorting should be necessary. Thanks so much! I see. And I will have a try. > > -- Steve > Best regards! -- Yinan liu