Re: [PATCH v2] smp: Document preemption and stop_machine() mutual exclusion

2025-07-08 Thread Peter Zijlstra
On Mon, Jul 07, 2025 at 08:56:04AM -0700, Paul E. McKenney wrote: > On Mon, Jul 07, 2025 at 09:50:50AM +0200, Peter Zijlstra wrote: > > On Sat, Jul 05, 2025 at 01:23:27PM -0400, Joel Fernandes wrote: > > > Recently while revising RCU's cpu online checks, there was some disc

Re: [PATCH v2] smp: Document preemption and stop_machine() mutual exclusion

2025-07-08 Thread Peter Zijlstra
On Mon, Jul 07, 2025 at 10:19:52AM -0400, Joel Fernandes wrote: > From: Joel Fernandes > Subject: [PATCH] smp: Document preemption and stop_machine() mutual exclusion > > Recently while revising RCU's cpu online checks, there was some discussion > around how IPIs synchronize with hotplug. > > A

Re: [PATCH v2] smp: Document preemption and stop_machine() mutual exclusion

2025-07-07 Thread Peter Zijlstra
On Sat, Jul 05, 2025 at 01:23:27PM -0400, Joel Fernandes wrote: > Recently while revising RCU's cpu online checks, there was some discussion > around how IPIs synchronize with hotplug. > > Add comments explaining how preemption disable creates mutual exclusion with > CPU hotplug's stop_machine mec

Re: [PATCH v3 44/64] x86/jump_label: Define ELF section entry size for jump labels

2025-06-30 Thread Peter Zijlstra
On Fri, Jun 27, 2025 at 09:55:30AM -0700, Josh Poimboeuf wrote: > On Fri, Jun 27, 2025 at 12:48:18PM +0200, Peter Zijlstra wrote: > > > +#define JUMP_TABLE_ENTRY(key, label) \ > > > + ".pushsection __jump_table, \"aM\", @pro

Re: [PATCH v3 42/64] kbuild,x86: Fix special section module permissions

2025-06-30 Thread Peter Zijlstra
On Fri, Jun 27, 2025 at 10:34:15AM -0700, Josh Poimboeuf wrote: > On Fri, Jun 27, 2025 at 12:53:28PM +0200, Peter Zijlstra wrote: > > On Thu, Jun 26, 2025 at 04:55:29PM -0700, Josh Poimboeuf wrote: > > > An upcoming patch will add the SHF_MERGE flag to x86 __jump_table and &g

Re: [PATCH v3 26/64] objtool: Add section/symbol type helpers

2025-06-30 Thread Peter Zijlstra
On Fri, Jun 27, 2025 at 09:36:08AM -0700, Josh Poimboeuf wrote: > On Fri, Jun 27, 2025 at 12:29:30PM +0200, Peter Zijlstra wrote: > > Naming seems inconsistent, there are: > > > > sym_has_sec(), sec_changed() and sec_size() > > > > which have the object

Re: [PATCH v3 42/64] kbuild,x86: Fix special section module permissions

2025-06-27 Thread Peter Zijlstra
On Thu, Jun 26, 2025 at 04:55:29PM -0700, Josh Poimboeuf wrote: > An upcoming patch will add the SHF_MERGE flag to x86 __jump_table and > __bug_table so their entry sizes can be defined in inline asm. > > However, those sections have SHF_WRITE, which the Clang linker (lld) > explicitly forbids com

Re: [PATCH v3 46/64] x86/extable: Define ELF section entry size for exception table

2025-06-27 Thread Peter Zijlstra
On Thu, Jun 26, 2025 at 04:55:33PM -0700, Josh Poimboeuf wrote: > @@ -193,7 +193,8 @@ static __always_inline __pure void *rip_rel_ptr(void *p) > ".purgem extable_type_reg\n" > > # define _ASM_EXTABLE_TYPE(from, to, type) \ > - " .pushsection \"__ex_table\",\"a\"\n"

Re: [PATCH v3 45/64] x86/static_call: Define ELF section entry size of static calls

2025-06-27 Thread Peter Zijlstra
On Thu, Jun 26, 2025 at 04:55:32PM -0700, Josh Poimboeuf wrote: > In preparation for the objtool klp diff subcommand, define the entry > size for the .static_call_sites section in its ELF header. This will > allow tooling to extract individual entries. > > Signed-off-by: Josh Poimboeuf > --- >

Re: [PATCH v3 44/64] x86/jump_label: Define ELF section entry size for jump labels

2025-06-27 Thread Peter Zijlstra
On Thu, Jun 26, 2025 at 04:55:31PM -0700, Josh Poimboeuf wrote: > In preparation for the objtool klp diff subcommand, define the entry > size for the __jump_table section in its ELF header. This will allow > tooling to extract individual entries. > > Signed-off-by: Josh Poimboeuf > --- > arch/x

Re: [PATCH v3 29/64] objtool: Mark prefix functions

2025-06-27 Thread Peter Zijlstra
On Thu, Jun 26, 2025 at 04:55:16PM -0700, Josh Poimboeuf wrote: > In preparation for the objtool klp diff subcommand, introduce a flag to > identify __pfx_*() and __cfi_*() functions in advance so they don't need > to be manually identified every time a check is needed. > > Signed-off-by: Josh Poi

Re: [PATCH v3 26/64] objtool: Add section/symbol type helpers

2025-06-27 Thread Peter Zijlstra
On Thu, Jun 26, 2025 at 04:55:13PM -0700, Josh Poimboeuf wrote: > @@ -177,11 +178,71 @@ static inline unsigned int elf_text_rela_type(struct > elf *elf) > return elf_addr_size(elf) == 4 ? R_TEXT32 : R_TEXT64; > } > > +static inline bool sym_has_sec(struct symbol *sym) > +{ > + return

Re: [PATCH v3 17/64] objtool: Fix weak symbol detection

2025-06-27 Thread Peter Zijlstra
On Thu, Jun 26, 2025 at 04:55:04PM -0700, Josh Poimboeuf wrote: > find_symbol_hole_containing() fails to find a symbol hole (aka stripped > weak symbol) if its section has no symbols before the hole. This breaks > weak symbol detection if -ffunction-sections is enabled. > > Fix that by allowing t

Re: [PATCH 4/8] shazptr: Avoid synchronize_shaptr() busy waiting

2025-06-25 Thread Peter Zijlstra
Response is a bit weird because non-linear editing.. On Tue, Jun 24, 2025 at 08:10:57PM -0700, Boqun Feng wrote: > + /* Whether the scan kthread has been scheduled to scan */ > + bool scheduled; > +static int __noreturn shazptr_scan_kthread(void *unused) > +{ > + for (;;) { > +

Re: [PATCH 8/8] locking/lockdep: Use shazptr to protect the key hashlist

2025-06-25 Thread Peter Zijlstra
On Tue, Jun 24, 2025 at 08:11:01PM -0700, Boqun Feng wrote: > + /* Need preemption disable for using shazptr. */ > + guard(preempt)(); > + > + /* Protect the list search with shazptr. */ > + guard(shazptr)(hash_head); OK, this is the end of the series, and so far every single user

Re: [PATCH 4/8] shazptr: Avoid synchronize_shaptr() busy waiting

2025-06-25 Thread Peter Zijlstra
On Tue, Jun 24, 2025 at 08:10:57PM -0700, Boqun Feng wrote: > +/* Scan structure for synchronize_shazptr(). */ > +struct shazptr_scan { > + /* The scan kthread */ > + struct task_struct *thread; > + > + /* Wait queue for the scan kthread */ > + struct swait_queue_head wq; > + > +

Re: [PATCH 1/8] Introduce simple hazard pointers

2025-06-25 Thread Peter Zijlstra
On Tue, Jun 24, 2025 at 08:10:54PM -0700, Boqun Feng wrote: > As its name suggests, simple hazard pointers (shazptr) is a > simplification of hazard pointers [1]: it has only one hazard pointer > slot per-CPU and is targeted for simple use cases where the read-side > already has preemption disabled

Re: [PATCH 2/8] shazptr: Add refscale test

2025-06-25 Thread Peter Zijlstra
On Tue, Jun 24, 2025 at 08:10:55PM -0700, Boqun Feng wrote: > Add the refscale test for shazptr to measure the reader side > performance. > > Signed-off-by: Boqun Feng > --- > kernel/rcu/refscale.c | 39 +++ > 1 file changed, 39 insertions(+) > > diff --git a

Re: [PATCH 3/8] shazptr: Add refscale test for wildcard

2025-06-25 Thread Peter Zijlstra
On Tue, Jun 24, 2025 at 08:10:56PM -0700, Boqun Feng wrote: > +static void ref_shazptr_wc_read_section(const int nloops) > +{ > + int i; > + > + for (i = nloops; i >= 0; i--) { > + preempt_disable(); > + { > + guard(shazptr)(ref_shazptr_read_sect

Re: [PATCH bpf 2/7] bpf/x86: prevent trampoline attachment when args location on stack is uncertain

2025-06-13 Thread Peter Zijlstra
On Fri, Jun 13, 2025 at 10:26:37AM +0200, Alexis Lothoré wrote: > Hi Peter, > > On Fri Jun 13, 2025 at 10:11 AM CEST, Peter Zijlstra wrote: > > On Fri, Jun 13, 2025 at 09:37:11AM +0200, Alexis Lothoré (eBPF Foundation) > > wrote: > >> When the target functio

Re: [PATCH bpf 2/7] bpf/x86: prevent trampoline attachment when args location on stack is uncertain

2025-06-13 Thread Peter Zijlstra
On Fri, Jun 13, 2025 at 09:37:11AM +0200, Alexis Lothoré (eBPF Foundation) wrote: > When the target function receives more arguments than available > registers, the additional arguments are passed on stack, and so the > generated trampoline needs to read those to prepare the bpf context, > but als

Re: [PATCH v2 32/62] objtool: Suppress section skipping warnings with --dryrun

2025-06-05 Thread Peter Zijlstra
On Thu, Jun 05, 2025 at 09:32:46AM +0200, Peter Zijlstra wrote: > > But also, feel free to resurrect --backup, or you can yell at me to do > > it as the backup code changed a bit. > > I have the patch somewhere, failed to send it out. I'll try and dig it > out later

Re: [PATCH v2] module: Make sure relocations are applied to the per-CPU section

2025-06-05 Thread Peter Zijlstra
On Thu, Jun 05, 2025 at 03:44:23PM +0200, Petr Pavlu wrote: > For instance: > > /* >* Don't bother with non-allocated sections. >* >* An exception is the percpu section, which has separate allocations >* for individual CPUs. We relocate the percpu section in

Re: [PATCH v2 32/62] objtool: Suppress section skipping warnings with --dryrun

2025-06-05 Thread Peter Zijlstra
On Wed, Jun 04, 2025 at 05:19:51PM -0700, Josh Poimboeuf wrote: > On Wed, May 28, 2025 at 12:34:53PM +0200, Peter Zijlstra wrote: > > On Mon, May 26, 2025 at 12:52:40PM +0200, Peter Zijlstra wrote: > > > On Fri, May 09, 2025 at 01:16:56PM -0700, Josh Poimboeuf wrote: > >

Re: [PATCH v2 32/62] objtool: Suppress section skipping warnings with --dryrun

2025-05-28 Thread Peter Zijlstra
On Mon, May 26, 2025 at 12:52:40PM +0200, Peter Zijlstra wrote: > On Fri, May 09, 2025 at 01:16:56PM -0700, Josh Poimboeuf wrote: > > It's common to use --dryrun on binaries that have already been > > processed. Don't print the section skipping warnings in that case. &g

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +#define KLP_RELOC_SEC_PREFIX ".klp.rela." > +#define KLP_SYM_PREFIX ".klp.sym." This max symbol length test is getting more and more broken every day :-)

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > diff --git a/tools/objtool/include/objtool/elf.h > b/tools/objtool/include/objtool/elf.h > index 4cfd09e66cb5..f62ac8081f27 100644 > --- a/tools/objtool/include/objtool/elf.h > +++ b/tools/objtool/include/objtool/elf.h > @@ -17,6 +1

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
Let me hand you a fresh bucket of curlies, you must've run out :-) On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +static struct symbol *first_file_symbol(struct elf *elf) > +{ > + struct symbol *sym; > + > + for_each_sym(elf, sym) { > + if (is_file_sym

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > +#define SEC_NAME_LEN 512 > #define SYM_NAME_LEN 512 > > +static int validate_ffunction_fdata_sections(struct elf *elf) > +{ > + struct symbol *sym; > + bool found_text = false, found_data = false; > + > +

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c > index cdf385e54c69..ae4f83fcbadf 100644 > --- a/tools/objtool/arch/x86/decode.c > +++ b/tools/objtool/arch/x86/decode.c > @@ -95,6 +95,46 @@ s64 arch_in

Re: [PATCH v2 52/62] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:16PM -0700, Josh Poimboeuf wrote: > Without '-ffunction-sections -fdata-sections', reliable object diffing > would be infeasible due to toolchain limitations: > > - For intra-file+intra-section references, the compiler might > occasionally generated hard-coded

Re: [PATCH v2 42/62] kbuild,x86: Fix module permissions for __jump_table and __bug_table

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:17:06PM -0700, Josh Poimboeuf wrote: > An upcoming patch will add the SHF_MERGE flag to x86 __jump_table and > __bug_table so their entry sizes can be defined in inline asm. > > However, those sections have SHF_WRITE, which the Clang linker (lld) > explicitly forbids com

Re: [PATCH v2 32/62] objtool: Suppress section skipping warnings with --dryrun

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:16:56PM -0700, Josh Poimboeuf wrote: > It's common to use --dryrun on binaries that have already been > processed. Don't print the section skipping warnings in that case. Ah, I rather like this warning, it gives me an easy check to see if the file has already been proce

Re: [PATCH v2 29/62] objtool: Mark prefix functions

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:16:53PM -0700, Josh Poimboeuf wrote: > In preparation for the objtool klp diff subcommand, introduce a flag to > identify __pfx_*() and __cfi_*() functions in advance so they don't need > to be manually identified every time a check is needed. > > Signed-off-by: Josh Poi

Re: [PATCH v2 28/62] objtool: Fix weak symbol hole detection for .cold functions

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:16:52PM -0700, Josh Poimboeuf wrote: > When ignore_unreachable_insn() looks for weak function holes which jump > to their .cold functions, it assumes the parent function comes before > the corresponding .cold function in the symbol table. That's not > necessarily the cas

Re: [PATCH v2 18/62] objtool: Fix x86 addend calculation

2025-05-26 Thread Peter Zijlstra
On Fri, May 09, 2025 at 01:16:42PM -0700, Josh Poimboeuf wrote: > On x86, arch_dest_reloc_offset() hardcodes the addend adjustment to > four, but the actual adjustment depends on the relocation type. Fix > that. > +s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc *reloc) > {

Re: [PATCH v2] sched,livepatch: Untangle cond_resched() and live-patching

2025-05-14 Thread Peter Zijlstra
On Wed, May 14, 2025 at 11:51:44AM +0200, Petr Mladek wrote: > IMHO, it might be easier when it goes via tip. Peter, feel free to > take it. Done! > Reviewed-by: Petr Mladek > Tested-by: Petr Mladek For some reason b4 didn't pick up these tags, added them manually and force pushed it again.

Re: [PATCH v2] sched,livepatch: Untangle cond_resched() and live-patching

2025-05-13 Thread Peter Zijlstra
On Tue, May 13, 2025 at 03:34:50PM +0200, Miroslav Benes wrote: > Hi, > > thanks for the updated version. > > On Fri, 9 May 2025, Sebastian Andrzej Siewior wrote: > > > From: Peter Zijlstra > > > > With the goal of deprecating / removing VOLUNTARY preempt,

[PATCH v3 3/5] module: Extend the MODULE_ namespace parsing

2025-05-02 Thread Peter Zijlstra
Instead of only accepting "module:${name}", extend it with a comma separated list of module names and add tail glob support. That is, something like: "module:foo-*,bar" is now possible. Signed-off-by: Peter Zijlstra (Intel) --- kernel/m

[PATCH v3 2/5] module: Add module specific symbol namespace support

2025-05-02 Thread Peter Zijlstra
Designate the "module:${modname}" symbol namespace to mean: 'only export to the named module'. Notably, explicit imports of anything in the "module:" space is forbidden. Signed-off-by: Peter Zijlstra (Intel) --- kernel/module/main.c | 33

[PATCH v3 4/5] module: Account for the build time module name mangling

2025-05-02 Thread Peter Zijlstra
Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle the module name with s/-/_/g. Since this happens late in the build, only the kernel needs to bother with this, the modpost tool still sees the original name. Reported-by: Sean Christopherson Signed-off-by: Peter Zijlstra

[PATCH v3 1/5] modpost: Use for() loop

2025-05-02 Thread Peter Zijlstra
Slight cleanup by using a for() loop instead of while(). This makes it clearer what is the iteration and what is the actual work done. Signed-off-by: Peter Zijlstra (Intel) --- scripts/mod/modpost.c |8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/scripts/mod/modpost.c

[PATCH v3 5/5] module: Provide EXPORT_SYMBOL_GPL_FOR_MODULES() helper

2025-05-02 Thread Peter Zijlstra
d failures). Requested-by: Masahiro Yamada Requested-by: Christoph Hellwig Signed-off-by: Peter Zijlstra (Intel) --- Documentation/core-api/symbol-namespaces.rst | 22 ++ include/linux/export.h | 12 ++-- 2 files changed, 32 insertions(+), 2

[PATCH v3 0/5] module: Strict per-modname namespaces

2025-05-02 Thread Peter Zijlstra
Hi! Implement means for exports to be available to an explicit list of named modules. By explicitly limiting the usage of certain exports, the abuse potential/risk is greatly reduced. Changes since v2: - switch to "module:" prefix (Masahiro) - removed some patch noise (Masahiro) - strstarts()

Re: [PATCH -v2 6/7] module: Account for the build time module name mangling

2025-05-02 Thread Peter Zijlstra
On Mon, Dec 02, 2024 at 03:59:52PM +0100, Peter Zijlstra wrote: > Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle > the module name with s/-/_/g. > > Since this happens late in the build, only the kernel needs to bother > with this, the modpost tool still se

Re: [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing

2025-05-02 Thread Peter Zijlstra
On Sat, Feb 08, 2025 at 12:45:21AM +0900, Masahiro Yamada wrote: > On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra wrote: > > > > Instead of only accepting "MODULE_${name}", extend it with a comma > > separated list of module names and add tail glob support.

Re: [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing

2025-05-02 Thread Peter Zijlstra
On Fri, Feb 07, 2025 at 05:41:54PM +0900, Masahiro Yamada wrote: > > +static bool verify_module_namespace(const char *namespace, const char > > *modname) > > +{ > > + size_t len, modlen = strlen(modname); > > + const char *sep; > > + bool glob; > > + > > + if (strncmp(name

Re: [PATCH -v2 0/7] module: Strict per-modname namespaces

2025-05-02 Thread Peter Zijlstra
On Fri, May 02, 2025 at 11:55:54AM +, Roy, Patrick wrote: > Hi Peter, > > Are you still working on this patch series? I'm working on having KVM remove > virtual machine memory from the kernel's direct map, to harden again > speculative execution attacks [1]. At David H.'s LSF/MM/BPF task on >

Re: [PATCH v3 3/3] selftests: pidfd: add tests for PIDFD_SELF_*

2025-05-01 Thread Peter Zijlstra
On Thu, May 01, 2025 at 01:42:35PM +0200, Peter Zijlstra wrote: > On Wed, Oct 16, 2024 at 07:14:34PM -0700, John Hubbard wrote: > > On 10/16/24 3:06 PM, Lorenzo Stoakes wrote: > > > On Wed, Oct 16, 2024 at 02:00:27PM -0600, Shuah Khan wrote: > > > > On 10/16/2

Re: [PATCH v3 3/3] selftests: pidfd: add tests for PIDFD_SELF_*

2025-05-01 Thread Peter Zijlstra
On Wed, Oct 16, 2024 at 07:14:34PM -0700, John Hubbard wrote: > On 10/16/24 3:06 PM, Lorenzo Stoakes wrote: > > On Wed, Oct 16, 2024 at 02:00:27PM -0600, Shuah Khan wrote: > > > On 10/16/24 04:20, Lorenzo Stoakes wrote: > ... > > > > diff --git a/tools/testing/selftests/pidfd/pidfd.h > > > > b/too

Re: [PATCH v4 10/38] perf/x86: Support switch_guest_ctx interface

2025-04-25 Thread Peter Zijlstra
On Fri, Apr 25, 2025 at 09:06:26AM -0400, Liang, Kan wrote: > > > On 2025-04-25 7:15 a.m., Peter Zijlstra wrote: > > On Mon, Mar 24, 2025 at 05:30:50PM +, Mingwei Zhang wrote: > >> From: Kan Liang > >> > >> Implement switch_guest_ctx inte

Re: [PATCH v4 00/38] Mediated vPMU 4.0 for x86

2025-04-25 Thread Peter Zijlstra
On Wed, Apr 16, 2025 at 03:22:02PM +0800, Mi, Dapeng wrote: > Kindly ping... Any comments on this patch series? Thanks. I suppose its mostly okay, just a few nits.

Re: [PATCH v4 10/38] perf/x86: Support switch_guest_ctx interface

2025-04-25 Thread Peter Zijlstra
On Mon, Mar 24, 2025 at 05:30:50PM +, Mingwei Zhang wrote: > From: Kan Liang > > Implement switch_guest_ctx interface for x86 PMU, switch PMI to dedicated > KVM_GUEST_PMI_VECTOR at perf guest enter, and switch PMI back to > NMI at perf guest exit. > > Signed-off-by: Xiong Zhang > Signed-off

Re: [PATCH v4 05/38] perf: Add generic exclude_guest support

2025-04-25 Thread Peter Zijlstra
On Mon, Mar 24, 2025 at 05:30:45PM +, Mingwei Zhang wrote: > @@ -6040,6 +6041,71 @@ void perf_put_mediated_pmu(void) > } > EXPORT_SYMBOL_GPL(perf_put_mediated_pmu); > > +static inline void perf_host_exit(struct perf_cpu_context *cpuctx) > +{ > + perf_ctx_disable(&cpuctx->ctx, EVENT_GUE

Re: [PATCH v4 09/38] perf: Add switch_guest_ctx() interface

2025-04-25 Thread Peter Zijlstra
On Mon, Mar 24, 2025 at 05:30:49PM +, Mingwei Zhang wrote: > @@ -1822,7 +1835,7 @@ extern int perf_event_period(struct perf_event *event, > u64 value); > extern u64 perf_event_pause(struct perf_event *event, bool reset); > int perf_get_mediated_pmu(void); > void perf_put_mediated_pmu(void)

Re: [PATCH v3 15/28] module: Use RCU in all users of __module_text_address().

2025-04-24 Thread Peter Zijlstra
On Thu, Apr 24, 2025 at 11:30:39AM +0200, Benjamin Berg wrote: > Not sure if something like that would be desirable upstream. This is > happening for us when running the hostap "hwsim" tests inside UML (with > time-travel). At least internally, we could carry a custom patch to add > the lockdep_of

Re: Symbol too long for allsyms warnings on KSYM_NAME_LEN

2025-03-27 Thread Peter Zijlstra
On Thu, Mar 27, 2025 at 09:38:46AM +0100, Arnd Bergmann wrote: > My randconfig builds sometimes (around one in every 700 configs) run > into this warning on x86: > > Symbol > __pfx_sg1h2i3j4k5l6m7ng1h2i3j4k5l6m7nng1h2i3j4k5l6m7ng1h2i3j4k5l6m7nnng1h2i3j4k5l6m7ng1h2i3j4k5l6m7nng1h2i3j4k5l6m7ng1

Re: [RFC][PATCH] sched,livepatch: Untangle cond_resched() and live-patching

2025-03-26 Thread Peter Zijlstra
On Wed, Mar 26, 2025 at 03:37:50PM +0100, Miroslav Benes wrote: > If I remember correctly, we had something like this in the old kGraft > implementation of the live patching (SUSE way). We exactly had a hook > somewhere in the kthread freezing code. This looks much cleaner and as far > as I kno

Re: [RFC][PATCH] sched,livepatch: Untangle cond_resched() and live-patching

2025-03-26 Thread Peter Zijlstra
On Wed, Mar 26, 2025 at 10:49:10AM +0100, Petr Mladek wrote: > On Mon 2025-03-24 14:49:09, Peter Zijlstra wrote: > > > > With the goal of deprecating / removing VOLUNTARY preempt, live-patch > > needs to stop relying on cond_resched() to make forward progress. > > &g

[RFC][PATCH] sched,livepatch: Untangle cond_resched() and live-patching

2025-03-24 Thread Peter Zijlstra
tested only. Signed-off-by: Peter Zijlstra (Intel) --- include/linux/livepatch_sched.h | 15 + include/linux/sched.h | 6 - kernel/livepatch/transition.c | 30 ++--- kernel/sched/core.c | 50 +++-- 4

Re: [PATCH] selftests/x86/lam: fix memory leak and resource leak in lam.c

2025-03-24 Thread Peter Zijlstra
On Mon, Mar 24, 2025 at 06:17:50PM +0530, Malaya Kumar Rout wrote: > Static Analyis for bench_htab_mem.c with cppcheck:error > tools/testing/selftests/x86/lam.c:585:3: > error: Resource leak: file_fd [resourceLeak] > tools/testing/selftests/x86/lam.c:593:3: > error: Resource leak: file_fd [resource

Re: [PATCH v2] ww_mutex: convert self-test to KUnit

2025-02-14 Thread Peter Zijlstra
On Thu, Feb 13, 2025 at 10:42:24AM -0500, Tamir Duberstein wrote: > On Thu, Feb 13, 2025 at 6:59 AM Peter Zijlstra wrote: > > > > On Thu, Feb 13, 2025 at 06:40:20AM -0500, Tamir Duberstein wrote: > > > Convert this unit test to a KUnit test. This allows the test to bene

Re: [PATCH] module: don't annotate ROX memory as kmemleak_not_leak()

2025-02-14 Thread Peter Zijlstra
On Fri, Feb 14, 2025 at 10:45:31AM +0200, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > The ROX memory allocations are part of a larger vmalloc allocation and > annotating them with kmemleak_not_leak() confuses kmemleak. > > Skip kmemleak_not_leak() annotations for the ROX areas.

Re: [PATCH v2] ww_mutex: convert self-test to KUnit

2025-02-13 Thread Peter Zijlstra
On Thu, Feb 13, 2025 at 06:40:20AM -0500, Tamir Duberstein wrote: > Convert this unit test to a KUnit test. This allows the test to benefit > from the KUnit tooling. Note that care is taken to avoid test-ending > assertions in worker threads, which is unsafe in KUnit (and wasn't done > before this

Re: [PATCH rcu 13/17] srcu: Add SRCU-fast readers

2025-01-16 Thread Peter Zijlstra
On Thu, Jan 16, 2025 at 01:00:24PM -0800, Alexei Starovoitov wrote: > On Thu, Jan 16, 2025 at 12:21 PM Paul E. McKenney wrote: > > > > +/* > > + * Counts the new reader in the appropriate per-CPU element of the > > + * srcu_struct. Returns a pointer that must be passed to the matching > > + * src

Re: [PATCH v2 00/28] module: Use RCU instead of RCU-sched.

2025-01-07 Thread Peter Zijlstra
.org/all/20241205215102.hrywu...@linutronix.de/ > - Splitted into smaller patches. > - Converted all users. Thanks for doing the cleanup! Acked-by: Peter Zijlstra (Intel)

Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal

2024-12-02 Thread Peter Zijlstra
On Mon, Dec 02, 2024 at 03:59:47PM +0100, Peter Zijlstra wrote: > Clean up the existing export namespace code along the same lines of > 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to > __section("foo")") and for the same reason, it is not desired

[PATCH -v2 6/7] module: Account for the build time module name mangling

2024-12-02 Thread Peter Zijlstra
Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle the module name with s/-/_/g. Since this happens late in the build, only the kernel needs to bother with this, the modpost tool still sees the original name. Reported-by: Sean Christopherson Signed-off-by: Peter Zijlstra

[PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper

2024-12-02 Thread Peter Zijlstra
Requested-by: Masahiro Yamada Requested-by: Christoph Hellwig Signed-off-by: Peter Zijlstra (Intel) --- include/linux/export.h | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) --- a/include/linux/export.h +++ b/include/linux/export.h @@ -24,11 +24,23

[PATCH -v2 0/7] module: Strict per-modname namespaces

2024-12-02 Thread Peter Zijlstra
Hi! Implement a means for exports to be available only to an explicit list of named modules. By explicitly limiting the usage of certain exports, the abuse potential/risk is greatly reduced. The first 'patch' is an awk scripts that cleans up the existing module namespace code along the same lines

[PATCH -v2 3/7] module/modpost: Add basename helper

2024-12-02 Thread Peter Zijlstra
Signed-off-by: Peter Zijlstra (Intel) --- scripts/mod/modpost.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1553,6 +1553,16 @@ static void mod_set_crcs(struct module * free(buf); } +static

[PATCH -v2 2/7] module/modpost: Use for() loop

2024-12-02 Thread Peter Zijlstra
Signed-off-by: Peter Zijlstra (Intel) --- scripts/mod/modpost.c |7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1586,12 +1586,9 @@ static void read_symbols(const char *mod license

[PATCH -v2 4/7] module: Add module specific symbol namespace support

2024-12-02 Thread Peter Zijlstra
Designate the "MODULE_${modname}" symbol namespace to mean: 'only export to the named module'. Notably, explicit imports of anything in the "MODULE_" space is forbidden. Modules implicitly get the "MODULE_${modname}" namespace added. Signed-off-by: Pe

[PATCH -v2 1/7] module: Convert symbol namespace to string literal

2024-12-02 Thread Peter Zijlstra
OL_NS[^(]*)\(([^,]+), ([^)]+)\)/, "\\1(\\2, \"\\3\")", "g"); } } { print }' $file; done Requested-by: Masahiro Yamada Signed-off-by: Peter Zijlstra (Intel) --- Documentation/core-api/symbol-namespaces.rst

[PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing

2024-12-02 Thread Peter Zijlstra
Instead of only accepting "MODULE_${name}", extend it with a comma separated list of module names and add tail glob support. That is, something like: "MODULE_foo-*,bar" is now possible. Signed-off-by: Peter Zijlstra (Intel) --- kernel/m

Re: [RFC][PATCH 0/8] module: Strict per-modname namespaces

2024-11-15 Thread Peter Zijlstra
On Tue, Nov 12, 2024 at 08:52:26PM +0100, Peter Zijlstra wrote: > On Tue, Nov 12, 2024 at 09:56:20AM -0800, Sean Christopherson wrote: > > > This likely needs to be addressed in whatever chunk of code is enforcing the > > namespaces. The s/-/_ behavior (and vice versa!) is *ve

Re: [RFC][PATCH 1/8] module: Prepare for script

2024-11-15 Thread Peter Zijlstra
On Mon, Nov 11, 2024 at 01:55:29PM +0100, Peter Zijlstra wrote: > On Mon, Nov 11, 2024 at 03:36:25AM -0800, Christoph Hellwig wrote: > > On Mon, Nov 11, 2024 at 11:54:31AM +0100, Peter Zijlstra wrote: > > > Since sed doesn't like multi-line make sure all EXPORT_SYMBOL_NS &g

Re: [RFC][PATCH 0/8] module: Strict per-modname namespaces

2024-11-12 Thread Peter Zijlstra
On Tue, Nov 12, 2024 at 09:56:20AM -0800, Sean Christopherson wrote: > This likely needs to be addressed in whatever chunk of code is enforcing the > namespaces. The s/-/_ behavior (and vice versa!) is *very* baked into the > kernel > at this point, e.g. parameqn() will happily parse dashes or u

Re: [RFC][PATCH 6/8] module: Add module specific symbol namespace support

2024-11-12 Thread Peter Zijlstra
On Mon, Nov 11, 2024 at 10:36:16AM -0800, Sean Christopherson wrote: > E.g. for x86, something like: > > #if IS_MODULE(CONFIG_KVM_AMD) && IS_MODULE(CONFIG_KVM_INTEL) > #define KVM_VENDOR_MODULES kvm-amd,kvm-intel > #elif IS_MODULE(CONFIG_KVM_AMD) > #define KVM_VENDOR_MODULES kvm-amd > #elif IS_MOD

Re: [RFC][PATCH 0/8] module: Strict per-modname namespaces

2024-11-12 Thread Peter Zijlstra
On Mon, Nov 11, 2024 at 04:48:58PM -0800, Sean Christopherson wrote: > On Mon, Nov 11, 2024, Peter Zijlstra wrote: > > Hi! > > > > Implement a means for exports to be available only to an explicit list of > > named > > modules. By explicitly limiting the us

Re: [RFC][PATCH 1/8] module: Prepare for script

2024-11-11 Thread Peter Zijlstra
On Mon, Nov 11, 2024 at 03:36:25AM -0800, Christoph Hellwig wrote: > On Mon, Nov 11, 2024 at 11:54:31AM +0100, Peter Zijlstra wrote: > > Since sed doesn't like multi-line make sure all EXPORT_SYMBOL_NS > > things are a single line. > > Eww. Just use coccinelle or anot

[RFC][PATCH 5/8] module/modpost: Add basename helper

2024-11-11 Thread Peter Zijlstra
Signed-off-by: Peter Zijlstra (Intel) --- scripts/mod/modpost.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1553,6 +1553,16 @@ static void mod_set_crcs(struct module * free(buf); } +static

[RFC][PATCH 7/8] module: Extend the MODULE_ namespace parsing

2024-11-11 Thread Peter Zijlstra
Instead of only accepting "MODULE_${name}", extend it with a comma separated list of module names and add tail glob support. That is, something like: "MODULE_foo-*,bar" is now possible. Signed-off-by: Peter Zijlstra (Intel) --- kernel/m

[RFC][PATCH 6/8] module: Add module specific symbol namespace support

2024-11-11 Thread Peter Zijlstra
Designate the "MODULE_${modname}" symbol namespace to mean: 'only export to the named module'. Notably, explicit imports of anything in the "MODULE_" space is forbidden. Modules implicitly get the "MODULE_${modname}" namespace added. Signed-off-by: Pe

[RFC][PATCH 0/8] module: Strict per-modname namespaces

2024-11-11 Thread Peter Zijlstra
Hi! Implement a means for exports to be available only to an explicit list of named modules. By explicitly limiting the usage of certain exports, the abuse potential/risk is greatly reduced. The first three 'patches' clean up the existing export namespace code along the same lines of 33def8498fdd

[RFC][PATCH 1/8] module: Prepare for script

2024-11-11 Thread Peter Zijlstra
Since sed doesn't like multi-line make sure all EXPORT_SYMBOL_NS things are a single line. Signed-off-by: Peter Zijlstra (Intel) --- drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 12 include/kunit/visibility.h|3 +-- sound/soc/codecs/tas2781-fmw

[RFC][PATCH 4/8] module/modpost: Use for() loop

2024-11-11 Thread Peter Zijlstra
Signed-off-by: Peter Zijlstra (Intel) --- scripts/mod/modpost.c |7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1586,12 +1586,9 @@ static void read_symbols(const char *mod license

[RFC][PATCH 8/8] module: Provide EXPORT_SYMBOL*_FOR() helpers

2024-11-11 Thread Peter Zijlstra
Because Christoph and Masahiro-san asked for it :-) Signed-off-by: Peter Zijlstra (Intel) --- include/linux/export.h |3 +++ 1 file changed, 3 insertions(+) --- a/include/linux/export.h +++ b/include/linux/export.h @@ -70,4 +70,7 @@ #define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL

[RFC][PATCH 3/8] module: Fix up after script

2024-11-11 Thread Peter Zijlstra
Signed-off-by: Peter Zijlstra (Intel) --- include/linux/export.h |4 ++-- include/linux/module.h |2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/include/linux/export.h +++ b/include/linux/export.h @@ -67,7 +67,7 @@ #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL

[RFC][PATCH 2/8] module: Convert symbol namespace to string literal

2024-11-11 Thread Peter Zijlstra
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file; do sed -i -e 's/MODULE_IMPORT_NS(\([^)]*\))/MODULE_IMPORT_NS("\1")/g' \ -e 's/\(EXPORT_SYMBOL_NS[^(]*\)(\([^,]*\), \([^)]*\))/\1(\2, "\3")/g' $file; done Signed-off-by: Peter Zijlstra (Intel) ---

Re: [RFC] module: Strict per-modname namespaces

2024-11-08 Thread Peter Zijlstra
On Fri, Nov 08, 2024 at 04:28:58PM +0100, H. Peter Anvin wrote: > >@@ -1700,11 +1715,7 @@ static void check_exports(struct module *mod) > > s->crc_valid = exp->crc_valid; > > s->crc = exp->crc; > > > >-basename = strrchr(mod->name, '/'); > >-if (base

Re: [RFC] module: Strict per-modname namespaces

2024-11-07 Thread Peter Zijlstra
On Thu, Nov 07, 2024 at 04:55:46PM +0900, Masahiro Yamada wrote: > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > > index 107393a8c48a..d1de3044ee03 100644 > > --- a/scripts/mod/modpost.c > > +++ b/scripts/mod/modpost.c > > @@ -1553,8 +1553,19 @@ static void mod_set_crcs(struct modu

Re: [RFC] module: Strict per-modname namespaces

2024-11-07 Thread Peter Zijlstra
On Thu, Nov 07, 2024 at 12:58:19PM +0100, Peter Zijlstra wrote: > Anyway, let me see about doing that whole ',' parsing thing people seem > to want. git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git module/namespace Seems to work with very limited testing.

[RFC] module: Strict per-modname namespaces

2024-11-06 Thread Peter Zijlstra
Hi, I've been wanting $topic for a while, and having just stumbled into the whole namespace thing by accident, I figured I'd give it a go, most if the hard parts seem to have already been done. It reserves and disallows imports on any "MODULE_${name}" namespace, while it implicitly adds the same

Re: [syzbot] [mm?] WARNING: locking bug in __rmqueue_pcplist

2024-11-04 Thread Peter Zijlstra
On Mon, Nov 04, 2024 at 12:25:03PM +0100, Vlastimil Babka wrote: > On 11/4/24 12:11, Vlastimil Babka wrote: > >> __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4771 > >> alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265 > >> stack_depot_save_flags+0x666/0x830 lib/stackdepot.c:627 > >>

Re: [syzbot] [mm?] WARNING: locking bug in __rmqueue_pcplist

2024-11-04 Thread Peter Zijlstra
On Mon, Nov 04, 2024 at 12:45:06PM +0100, Peter Zijlstra wrote: > diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c > index 6310a180278b..ac9f6682bb2f 100644 > --- a/mm/kasan/generic.c > +++ b/mm/kasan/generic.c > @@ -521,12 +521,12 @@ size_t kasan_metadata_size(struct km

Re: [PATCH rcu] srcu: Guarantee non-negative return value from srcu_read_lock()

2024-10-22 Thread Peter Zijlstra
On Tue, Oct 22, 2024 at 12:07:35AM -0700, Christoph Hellwig wrote: > On Tue, Oct 22, 2024 at 09:06:35AM +0200, Peter Zijlstra wrote: > > What is returned is an array index -- and SRCU is currently built using > > an array of size 2. Using larger arrays is conceivable (IIRC some

Re: [PATCH rcu] srcu: Guarantee non-negative return value from srcu_read_lock()

2024-10-22 Thread Peter Zijlstra
On Mon, Oct 21, 2024 at 08:30:43PM -0700, Paul E. McKenney wrote: > Thoughts? Thanks Paul! Acked-by: Peter Zijlstra (Intel) > > > commit 4433b7d3785d8d2a700f5ed5ca234c64bc63180e > Author: Paul E. McKenney

Re: [PATCH rcu] srcu: Guarantee non-negative return value from srcu_read_lock()

2024-10-22 Thread Peter Zijlstra
On Mon, Oct 21, 2024 at 11:51:40PM -0700, Christoph Hellwig wrote: > On Mon, Oct 21, 2024 at 03:13:05PM -0700, Paul E. McKenney wrote: > > For almost 20 years, the int return value from srcu_read_lock() has > > been always either zero or one. This commit therefore documents the > > fact that it wi

Re: [PATCH net-next v1 1/3] connector/cn_proc: Add hash table for threads

2024-10-14 Thread Peter Zijlstra
On Sun, Oct 13, 2024 at 10:06:15AM -0700, Anjali Kulkarni wrote: > + if (unlikely(task->flags & PF_EXIT_NOTIFY)) { > + task_lock(task); > + task->flags &= ~PF_EXIT_NOTIFY; > + task_unlock(task); > + > @@ -413,6 +440,15 @@ static void cn_proc_mcast_ctl(struc

  1   2   3   4   5   6   7   8   9   10   >