From: "Huang, Ying" <ying.huang@intel.com>
To: David Hildenbrand <david@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
x86@kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
Kai Huang <kai.huang@intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
Oscar Salvador <osalvador@suse.de>
Subject: Re: [PATCH -V2] tdx, memory hotplug: Check whole hot-adding memory range for TDX
Date: Fri, 11 Oct 2024 19:57:39 +0800 [thread overview]
Message-ID: <87r08m97ik.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <50881635-092f-4940-b998-1532d5c9f83a@redhat.com> (David Hildenbrand's message of "Fri, 11 Oct 2024 11:53:13 +0200")
David Hildenbrand <david@redhat.com> writes:
> On 11.10.24 11:48, David Hildenbrand wrote:
>> On 11.10.24 10:51, Huang, Ying wrote:
>>> David Hildenbrand <david@redhat.com> writes:
>>>
>>>> On 11.10.24 03:27, Huang, Ying wrote:
>>>>> David Hildenbrand <david@redhat.com> writes:
>>>>>
>>>>>>> extern u64 max_mem_size;
>>>>>>> extern int mhp_online_type_from_str(const char *str);
>>>>>>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>>>>>>> index 621ae1015106..c4769f24b1e2 100644
>>>>>>> --- a/mm/memory_hotplug.c
>>>>>>> +++ b/mm/memory_hotplug.c
>>>>>>> @@ -1305,6 +1305,11 @@ int try_online_node(int nid)
>>>>>>> return ret;
>>>>>>> }
>>>>>>> +int __weak arch_check_hotplug_memory_range(u64 start, u64 size)
>>>>>>> +{
>>>>>>> + return 0;
>>>>>>> +}
>>>>>>
>>>>>> BTW, I remember that "__weak" doesn't always behave the way it would
>>>>>> seem, which is the reason we're usually using
>>>>>>
>>>>>> #define arch_check_hotplug_memory_range arch_check_hotplug_memory_range
>>>>>>
>>>>>> #ifndef arch_check_hotplug_memory_range
>>>>>> ...
>>>>>> #endif
>>>>>>
>>>>>>
>>>>>> Not that I remember the details, just that it can result in rather
>>>>>> surprising outcomes (e.g., the wrong function getting called).
>>>>> I can replace __weak with #define/#ifndef.
>>>>> However, it appears that "__weak" is still widely used now.
>>>>
>>>> Probably better to avoid new ones.
>>>
>>> Sure. Will do that in the future versions.
>>>
>>>> See also
>>>> Documentation/dev-tools/checkpatch.rst
>>>>
>>>> I assume checkpatch.pl should complain as well?
>>>
>>> Double checked again. It doesn't complain for that.
>> Indeed, it only checks for usage of "weak" for *declarations*. So
>> maybe
>> it's fine after all and I am misremembering things. So just leave it as
>> is for the time being.
>>
>
> For completeness, this is the issue I remembered:
>
> commit 65d9a9a60fd71be964effb2e94747a6acb6e7015
> Author: Naveen N Rao <naveen@kernel.org>
> Date: Fri Jul 1 13:04:04 2022 +0530
>
> kexec_file: drop weak attribute from functions
> As requested
> (http://lkml.kernel.org/r/87ee0q7b92.fsf@email.froward.int.ebiederm.org),
> this series converts weak functions in kexec to use the #ifdef approach.
> Quoting the 3e35142ef99fe ("kexec_file: drop weak attribute
> from
> arch_kexec_apply_relocations[_add]") changelog:
> : Since commit d1bcae833b32f1 ("ELF: Don't generate unused
> section symbols")
> : [1], binutils (v2.36+) started dropping section symbols that it thought
> : were unused. This isn't an issue in general, but with kexec_file.c, gcc
> : is placing kexec_arch_apply_relocations[_add] into a separate
> : .text.unlikely section and the section symbol ".text.unlikely" is being
> : dropped. Due to this, recordmcount is unable to find a non-weak symbol in
> : .text.unlikely to generate a relocation record against.
Good to know this, Thanks!
--
Best Regards,
Huang, Ying
prev parent reply other threads:[~2024-10-11 12:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 7:47 Huang Ying
2024-10-10 12:40 ` David Hildenbrand
2024-10-11 1:27 ` Huang, Ying
2024-10-11 7:53 ` David Hildenbrand
2024-10-11 8:51 ` Huang, Ying
2024-10-11 9:48 ` David Hildenbrand
2024-10-11 9:53 ` David Hildenbrand
2024-10-11 11:57 ` Huang, Ying [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r08m97ik.fsf@yhuang6-desk2.ccr.corp.intel.com \
--to=ying.huang@intel.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=osalvador@suse.de \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox