Re: [PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance

2024-08-30 Thread Liao, Chang
在 2024/8/30 3:26, Andrii Nakryiko 写道: > On Tue, Aug 27, 2024 at 4:34 AM Liao, Chang wrote: >> >> Hi, Mark >> >> Would you like to discuss this patch further, or do you still believe >> emulating >> STP to push FP/LR into the stack in kernel is not a go

Re: [PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance

2024-08-27 Thread Liao, Chang
Hi, Mark Would you like to discuss this patch further, or do you still believe emulating STP to push FP/LR into the stack in kernel is not a good idea? Thanks. 在 2024/8/21 15:55, Liao, Chang 写道: > Hi, Mark > > My bad for taking so long to rely, I generally agree with your suggestions

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-21 Thread Liao, Chang
在 2024/8/16 0:53, Andrii Nakryiko 写道: > On Wed, Aug 14, 2024 at 7:58 PM Liao, Chang wrote: >> >> >> >> 在 2024/8/15 2:42, Andrii Nakryiko 写道: >>> On Tue, Aug 13, 2024 at 9:17 PM Liao, Chang wrote: >>>> >>>> >>>> >>

Re: [PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance

2024-08-21 Thread Liao, Chang
Hi, Mark My bad for taking so long to rely, I generally agree with your suggestions to STP emulation. 在 2024/8/15 17:58, Mark Rutland 写道: > On Wed, Aug 14, 2024 at 08:03:56AM +, Liao Chang wrote: >> As Andrii pointed out, the uprobe/uretprobe selftest bench run into a >> c

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-15 Thread Liao, Chang
在 2024/8/15 0:57, Andrii Nakryiko 写道: > On Tue, Aug 13, 2024 at 9:17 PM Liao, Chang wrote: >> >> >> >> 在 2024/8/13 1:49, Andrii Nakryiko 写道: >>> On Mon, Aug 12, 2024 at 4:11 AM Liao, Chang wrote: >>>> >>>> >>>> >&g

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-14 Thread Liao, Chang
在 2024/8/15 2:42, Andrii Nakryiko 写道: > On Tue, Aug 13, 2024 at 9:17 PM Liao, Chang wrote: >> >> >> >> 在 2024/8/13 1:49, Andrii Nakryiko 写道: >>> On Mon, Aug 12, 2024 at 4:11 AM Liao, Chang wrote: >>>> >>>> >>>> >&g

[PATCH v3 0/2] uprobes: Improve scalability by reducing the contention on siglock

2024-08-14 Thread Liao Chang
s://lore.kernel.org/all/20240727094405.1362496-1-liaocha...@huawei.com [3] https://lore.kernel.org/all/20240801082407.1618451-1-liaocha...@huawei.com Liao Chang (2): uprobes: Remove redundant spinlock in uprobe_deny_signal() uprobes: Remove the spinlock within handle_singlestep() include/linux/u

[PATCH v3 2/2] uprobes: Remove the spinlock within handle_singlestep()

2024-08-14 Thread Liao Chang
rg [2] https://lore.kernel.org/all/20240727094405.1362496-1-liaocha...@huawei.com Acked-by: Oleg Nesterov Signed-off-by: Liao Chang --- include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 8 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/uprobes.h b/in

[PATCH v3 1/2] uprobes: Remove redundant spinlock in uprobe_deny_signal()

2024-08-14 Thread Liao Chang
Since clearing a bit in thread_info is an atomic operation, the spinlock is redundant and can be removed, reducing lock contention is good for performance. Acked-by: Oleg Nesterov Signed-off-by: Liao Chang --- kernel/events/uprobes.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel

[PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance

2024-08-14 Thread Liao Chang
and 'ret' variants has been significantly reduced. Due to the emulation of 'push' instruction needs to access userspace memory, it spent more cycles than the other. [0] https://lore.kernel.org/all/caef4bzao4eg6hr2hzxypn+7uer4chs0r99zln02ezz5yruv...@mail.gmail.com/ Signed-off-by:

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-13 Thread Liao, Chang
在 2024/8/13 1:57, Andrii Nakryiko 写道: > On Mon, Aug 12, 2024 at 5:05 AM Liao, Chang wrote: >> >> >> >> 在 2024/8/10 2:40, Andrii Nakryiko 写道: >>> On Fri, Aug 9, 2024 at 11:34 AM Andrii Nakryiko >>> wrote: >>>> >>>> On Fri,

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-13 Thread Liao, Chang
在 2024/8/13 1:49, Andrii Nakryiko 写道: > On Mon, Aug 12, 2024 at 4:11 AM Liao, Chang wrote: >> >> >> >> 在 2024/8/9 2:26, Andrii Nakryiko 写道: >>> On Thu, Aug 8, 2024 at 1:45 AM Liao, Chang wrote: >>>> >>>> Hi Andrii and Oleg. >&g

Re: [PATCH v2 1/2] uprobes: Remove redundant spinlock in uprobe_deny_signal()

2024-08-13 Thread Liao, Chang
在 2024/8/12 20:07, Oleg Nesterov 写道: > On 08/09, Liao Chang wrote: >> >> Since clearing a bit in thread_info is an atomic operation, the spinlock >> is redundant and can be removed, reducing lock contention is good for >> performance. > > My ack still

Re: [PATCH v2 2/2] uprobes: Remove the spinlock within handle_singlestep()

2024-08-13 Thread Liao, Chang
在 2024/8/12 19:29, Oleg Nesterov 写道: > On 08/09, Liao Chang wrote: >> >> --- a/include/linux/uprobes.h >> +++ b/include/linux/uprobes.h >> @@ -75,6 +75,7 @@ struct uprobe_task { >> >> struct uprobe *active_uprobe; >>

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-12 Thread Liao, Chang
在 2024/8/10 2:40, Andrii Nakryiko 写道: > On Fri, Aug 9, 2024 at 11:34 AM Andrii Nakryiko > wrote: >> >> On Fri, Aug 9, 2024 at 12:16 AM Liao, Chang wrote: >>> >>> >>> >>> 在 2024/8/9 2:26, Andrii Nakryiko 写道: >>>> On Thu, Aug 8,

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-12 Thread Liao, Chang
在 2024/8/9 2:26, Andrii Nakryiko 写道: > On Thu, Aug 8, 2024 at 1:45 AM Liao, Chang wrote: >> >> Hi Andrii and Oleg. >> >> This patch sent by me two weeks ago also aim to optimize the performance of >> uprobe >> on arm64. I notice recent discussion

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-09 Thread Liao, Chang
在 2024/8/9 2:26, Andrii Nakryiko 写道: > On Thu, Aug 8, 2024 at 1:45 AM Liao, Chang wrote: >> >> Hi Andrii and Oleg. >> >> This patch sent by me two weeks ago also aim to optimize the performance of >> uprobe >> on arm64. I notice recent discussion

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-08 Thread Liao, Chang
ing the patch until Andrii's changes are settle down. > > Oleg. > > > On 08/08, Liao, Chang wrote: >> >> Hi Andrii and Oleg. >> >> This patch sent by me two weeks ago also aim to optimize the performance of >> uprobe >> on arm64. I

[PATCH v2 0/2] uprobes: Improve scalability by reducing the contention on siglock

2024-08-08 Thread Liao Chang
ps://lore.kernel.org/all/20240801082407.1618451-1-liaocha...@huawei.com Liao Chang (2): uprobes: Remove redundant spinlock in uprobe_deny_signal() uprobes: Remove the spinlock within handle_singlestep() include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 10 +- 2 files changed

[PATCH v2 2/2] uprobes: Remove the spinlock within handle_singlestep()

2024-08-08 Thread Liao Chang
rg [2] https://lore.kernel.org/all/20240727094405.1362496-1-liaocha...@huawei.com Signed-off-by: Liao Chang --- include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 8 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h

[PATCH v2 1/2] uprobes: Remove redundant spinlock in uprobe_deny_signal()

2024-08-08 Thread Liao Chang
Since clearing a bit in thread_info is an atomic operation, the spinlock is redundant and can be removed, reducing lock contention is good for performance. Acked-by: Oleg Nesterov Signed-off-by: Liao Chang --- kernel/events/uprobes.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel

Re: [PATCH] uprobes: Improve scalability by reducing the contention on siglock

2024-08-08 Thread Liao, Chang
在 2024/8/8 18:28, Oleg Nesterov 写道: > On 08/08, Liao, Chang wrote: >> >> - pre_ssout() resets the deny signal flag >> >> - uprobe_deny_signal() sets the deny signal flag when TIF_SIGPENDING is >> cleared. >> >> - handle_single

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-08 Thread Liao, Chang
he CC list for broader visibility and potential collaboration. Thanks. 在 2024/7/27 17:44, Liao Chang 写道: > The profiling result of single-thread model of selftests bench reveals > performance bottlenecks in find_uprobe() and caches_clean_inval_pou() on > ARM64. On my local testing mach

Re: [PATCH 0/8] uprobes: RCU-protected hot path optimizations

2024-08-08 Thread Liao, Chang
e. > [...] >> >> (To clarify. In fact I think that a new TIF_ or even PF_ flag makes more >> sense, >> afaics it can have more users. But I don't think that uprobes can provide >> enough >> justification for that right now) I also face the same choice when Oleg suggested me to add new flag to track the denied flag, due to I haven't encountered scenarios outside of uprobe that would deny signal, so I'm not confident of introduce new TIF_ flag without a fully understanding of potential potential impacts. >> >> Oleg. >> -- BR Liao, Chang

Re: [PATCH] uprobes: Improve scalability by reducing the contention on siglock

2024-08-08 Thread Liao, Chang
nal flag when TIF_SIGPENDING is cleared. - handle_singlestep() check the deny signal flag and restore TIF_SIGPENDING if necessary. Does this approach look correct to you,do do you have any other way to implement the "flag"? Thanks. > > Oleg. > > On 08/06, Oleg Nestero

Re: [PATCH] uprobes: Improve scalability by reducing the contention on siglock

2024-08-05 Thread Liao, Chang
在 2024/8/2 17:24, Oleg Nesterov 写道: > On 08/02, Liao, Chang wrote: >> >> >> 在 2024/8/1 22:06, Oleg Nesterov 写道: >>> On 08/01, Liao Chang wrote: >>>> >>>> @@ -2276,22 +2277,25 @@ static void handle_singlestep(struct uprobe_task

Re: [PATCH 6/8] perf/uprobe: split uprobe_unregister()

2024-08-05 Thread Liao, Chang
在 2024/8/6 4:01, Andrii Nakryiko 写道: > On Fri, Aug 2, 2024 at 8:05 AM Andrii Nakryiko > wrote: >> >> On Thu, Aug 1, 2024 at 7:41 PM Liao, Chang wrote: >>> >>> >>> >>> 在 2024/8/1 5:42, Andrii Nakryiko 写道: >>>> From:

Re: [PATCH 6/8] perf/uprobe: split uprobe_unregister()

2024-08-01 Thread Liao, Chang
nt_enable(struct trace_event_call *call, > diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c > b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c > index 73a6b041bcce..928c73cde32e 100644 > --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c > +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c > @@ -478,7 +478,8 @@ static void testmod_unregister_uprobe(void) > mutex_lock(&testmod_uprobe_mutex); > > if (uprobe.uprobe) { > - uprobe_unregister(uprobe.uprobe, &uprobe.consumer); > + uprobe_unregister_nosync(uprobe.uprobe, &uprobe.consumer); > + uprobe_unregister_sync(); > uprobe.offset = 0; > uprobe.uprobe = NULL; > } -- BR Liao, Chang

Re: [PATCH] uprobes: Improve scalability by reducing the contention on siglock

2024-08-01 Thread Liao, Chang
在 2024/8/1 22:06, Oleg Nesterov 写道: > On 08/01, Liao Chang wrote: >> >> @@ -2276,22 +2277,25 @@ static void handle_singlestep(struct uprobe_task >> *utask, struct pt_regs *regs) >> int err = 0; >> >> uprobe = utask->active_uprobe; &

Re: [PATCH 3/8] uprobes: protected uprobe lifetime with SRCU

2024-08-01 Thread Liao, Chang
在 2024/8/2 0:49, Andrii Nakryiko 写道: > On Thu, Aug 1, 2024 at 5:23 AM Liao, Chang wrote: >> >> >> >> 在 2024/8/1 5:42, Andrii Nakryiko 写道: >>> To avoid unnecessarily taking a (brief) refcount on uprobe during >>> breakpoint handling in handle_swbp

Re: [PATCH 3/8] uprobes: protected uprobe lifetime with SRCU

2024-08-01 Thread Liao, Chang
vaddr, &is_swbp); > if (!uprobe) { > if (is_swbp > 0) { > /* No matching uprobe; signal SIGTRAP. */ > @@ -2223,6 +2239,7 @@ static void handle_swbp(struct pt_regs *regs) > */ > instruction_pointer_set(regs, bp_vaddr); > } > + srcu_read_unlock(&uprobes_srcu, srcu_idx); > return; > } > > @@ -2258,12 +2275,12 @@ static void handle_swbp(struct pt_regs *regs) > if (arch_uprobe_skip_sstep(&uprobe->arch, regs)) > goto out; > > - if (!pre_ssout(uprobe, regs, bp_vaddr)) > - return; > + if (pre_ssout(uprobe, regs, bp_vaddr)) > + goto out; > Regardless what pre_ssout() returns, it always reach the label 'out', so the if block is unnecessary. > - /* arch_uprobe_skip_sstep() succeeded, or restart if can't singlestep */ > out: > - put_uprobe(uprobe); > + /* arch_uprobe_skip_sstep() succeeded, or restart if can't singlestep */ > + srcu_read_unlock(&uprobes_srcu, srcu_idx); > } > > /* -- BR Liao, Chang

[PATCH] uprobes: Improve scalability by reducing the contention on siglock

2024-08-01 Thread Liao Chang
f which are from 4.5M/s to 6.4M/s and 3.3M/s to 5.1M/s individually. [1] https://lore.kernel.org/all/20240731214256.3588718-1-and...@kernel.org [2] https://lore.kernel.org/all/20240727094405.1362496-1-liaocha...@huawei.com Signed-off-by: Liao Chang --- include/linux/uprobes.h | 1 + ke

[PATCH] uprobes: Remove redundant spinlock in uprobe_deny_signal

2024-07-31 Thread Liao Chang
Since clearing a bit in thread_info is an atomic operation, the spinlock is redundant and can be removed, reducing lock contention is good for performance. Signed-off-by: Liao Chang --- kernel/events/uprobes.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel

[PATCH v2] mm: add alloc_contig_migrate_range allocation statistics

2024-02-27 Thread Richard Chang
was quite useful to understand CMA allocation latency. Signed-off-by: Richard Chang --- * from v1 - https://lore.kernel.org/linux-mm/20240226100045.2083962-1-richard...@google.com/ * Move the trace event int field to the end of the longs - rostedt * Do the calculation only when tracing is

[PATCH] mm: add alloc_contig_migrate_range allocation statistics

2024-02-26 Thread Richard Chang
was quite useful to understand CMA allocation latency. Signed-off-by: Richard Chang --- include/trace/events/kmem.h | 39 + mm/internal.h | 3 ++- mm/page_alloc.c | 30 +++- mm/page_isolation.c | 2

[PATCH v2] riscv/kprobe: Restore local irqflag if kprobe is cancelled

2021-04-16 Thread Liao Chang
'SIE' is masked in this new saved irqflag. After kprobe is serviced, the CPU 'sstatus' is restored with 'SIE' masked. This overwritten 'sstatus' cause BUG_ON() in __find_get_block. This bug is already fixed on arm64 by Jisheng Zhang. Fixes: c22b0bcb1dd

Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-04-12 Thread Bae, Chang Seok
for 33 different real-time signals. Also, perhaps, force_sig(SIGFAIL) here, instead of return -1 -- to die with SIGSEGV. Thanks, Chang

[PATCH] riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe

2021-03-30 Thread Liao Chang
'SIE', and reach __find_get_block where it requires the interrupt must be enabled. Fix this is very trivial, just restore the value of 'sstatus' in pt_regs with backup one at 2) when the instruction being single stepped cause a page fault. Fixes: c22b0bcb1dd02 ("riscv: A

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-29 Thread Bae, Chang Seok
On Mar 26, 2021, at 09:34, Jann Horn wrote: > On Sun, Feb 21, 2021 at 7:56 PM Chang S. Bae wrote: >> >> + if (handle_xfirstuse_event(¤t->thread.fpu)) >> + return; > > What happens if handle_xfirstuse_event() fails because vmalloc() > failed

Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-25 Thread Bae, Chang Seok
sp - current->sas_ss_sp > current->sas_ss_size))) { > > You could've simply done > > if (unlikely(entering_altstack && !on_sig_stack(sp))) > > here. But if sigaltstack()’ed with the SS_AUTODISARM flag, both on_sig_stack() and sas_ss_flags() return 0 [1]. Then, segfault always here. v5 had the exact issue before [2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/sched/signal.h#n576 [2] https://lore.kernel.org/lkml/CALCETrXuFrHUU-L=HMofTgEDZk9muPnVtK=ejsthqq01xhb...@mail.gmail.com/ Thanks, Chang

Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-25 Thread Bae, Chang Seok
kernel-induced overflow -- whether alt stack enough for signal delivery itself. The stack is possibly not enough for the signal handler's use as the kernel does not know for it. Thanks, Chang

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-25 Thread Bae, Chang Seok
just what you mean. :) FWIW, PATCH21 [1] uses the instruction mask to skip writing zeros on sigframe. Then, XSAVE will clear the xstate_bv for the xtile data state bit. [1] https://lore.kernel.org/lkml/20210221185637.19281-22-chang.seok@intel.com/ Thanks, Chang

Re: [PATCH] btrfs: fix a potential hole-punching failure

2021-03-24 Thread bingjing chang
In order to reply in plain text, I send the mail from Gmail. Filipe Manana 於 2021年3月24日 週三 下午8:16寫道: > > On Wed, Mar 24, 2021 at 11:15 AM bingjingc wrote: > > > > From: BingJing Chang > > > > In commit d77815461f04 ("btrfs: Avoid trucating page or punching

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-23 Thread Bae, Chang Seok
On Mar 20, 2021, at 15:13, Thomas Gleixner wrote: > On Sun, Feb 21 2021 at 10:56, Chang S. Bae wrote: >> + >> +/* Update MSR IA32_XFD with xfirstuse_not_detected() if needed. */ >> +static inline void xdisable_switch(struct fpu *prev, struct fpu *next) >> +{

Re: [PATCH v4 16/22] x86/fpu/xstate: Extend the table to map state components with features

2021-03-23 Thread Bae, Chang Seok
[i])) > + if (xsave_cpuid_features[i] || > !boot_cpu_has(xsave_cpuid_features[i])) > xfeatures_mask_all &= ~BIT_ULL(i); > > Even with the gaps for XTILE the table is smaller, the code is simpler… True, I will follow your suggestion. Maybe follow-up with a new patch before posting v5. Thank you for the suggestion. Chang

Re: [PATCH v4 18/22] x86/fpu/amx: Define AMX state components and have it used for boot-time checks

2021-03-23 Thread Bae, Chang Seok
On Mar 20, 2021, at 14:31, Thomas Gleixner wrote: > On Sun, Feb 21 2021 at 10:56, Chang S. Bae wrote: >> >> +static void check_xtile_data_against_struct(int size) >> +{ >> +u32 max_palid, palid, state_size; >> +u32 eax, eb

Re: [PATCH v4 19/22] x86/fpu/amx: Enable the AMX feature in 64-bit mode

2021-03-23 Thread Bae, Chang Seok
On Mar 20, 2021, at 14:26, Thomas Gleixner wrote: > On Sun, Feb 21 2021 at 10:56, Chang S. Bae wrote: >> In 64-bit mode, include the AMX state components in >> XFEATURE_MASK_USER_SUPPORTED. >> >> The XFD feature will be used to dynamically expand the xstate per-task

Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-16 Thread Bae, Chang Seok
On Mar 16, 2021, at 04:52, Borislav Petkov wrote: > On Mon, Mar 15, 2021 at 11:52:14PM -0700, Chang S. Bae wrote: >> @@ -272,7 +275,8 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs >> *regs, size_t frame_size, >> * If we are on the alternate signal stack

[PATCH v7 4/6] selftest/sigaltstack: Use the AT_MINSIGSTKSZ aux vector if available

2021-03-15 Thread Chang S. Bae
The SIGSTKSZ constant may not represent enough stack size in some architectures as the hardware state size grows. Use getauxval(AT_MINSIGSTKSZ) to increase the stack size. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org

[PATCH v7 6/6] selftest/x86/signal: Include test cases for validating sigaltstack

2021-03-15 Thread Chang S. Bae
The test measures the kernel's signal delivery with different (enough vs. insufficient) stack sizes. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Revised test messages

[PATCH v7 3/6] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-03-15 Thread Chang S. Bae
Context Switch") Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: H.J. Lu Cc: Fenghua Yu Cc: Dave Martin Cc: Michael Ellerman Cc: x...@kernel.org Cc: libc-al...@sourceware.org Cc: linux-a...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-ke

[PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-15 Thread Chang S. Bae
ds. While the kernel allows new source code to discover and use a sufficient alternate signal stack size, this check is still necessary to protect binaries with insufficient alternate signal stack size from data corruption. Suggested-by: Jann Horn Signed-off-by: Chang S. Bae Reviewed-by: Len Brown

[PATCH v7 2/6] x86/signal: Introduce helpers to get the maximum signal frame size

2021-03-15 Thread Chang S. Bae
, and helper functions for the calculation to be used in a new user interface. Set max_frame_size to a system-wide worst-case value, instead of storing multiple app-specific values. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Acked-by: H.J. Lu Cc: x...@kernel.org Cc: linux-kernel

[PATCH v7 1/6] uapi: Define the aux vector AT_MINSIGSTKSZ

2021-03-15 Thread Chang S. Bae
Define the AT_MINSIGSTKSZ in generic Linux. It is already used as generic ABI in glibc's generic elf.h, and this define will prevent future namespace conflicts. In particular, x86 is also using this generic definition. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Carlos O'

[PATCH v7 0/6] x86: Improve Minimum Alternate Stack Size

2021-03-15 Thread Chang S. Bae
32757-1-chang.seok@intel.com/ Chang S. Bae (6): uapi: Define the aux vector AT_MINSIGSTKSZ x86/signal: Introduce helpers to get the maximum signal frame size x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ selftest/sigaltstack: Use the AT_MINSIGSTKSZ aux vector if available x86/s

[PATCH v4 2/4] sched/fair: Make CFS bandwidth controller burstable

2021-03-15 Thread Huaixin Chang
sysctl_sched_cfs_bw_burst_enabled is introduced as a switch for burst. It is enabled by default. Co-developed-by: Shanpei Chen Signed-off-by: Shanpei Chen Signed-off-by: Huaixin Chang --- include/linux/sched/sysctl.h | 1 + kernel/sched/core.c | 8 +++--- kernel/sched/fair.c | 58

[PATCH v4 3/4] sched/fair: Add cfs bandwidth burst statistics

2021-03-15 Thread Huaixin Chang
into cpu.stat file: nr_burst: number of periods bandwidth burst occurs burst_time: cumulative wall-time that any cpus has used above quota in respective periods Co-developed-by: Shanpei Chen Signed-off-by: Shanpei Chen Signed-off-by: Huaixin Chang --- kernel/sched/core.c | 14

[PATCH v4 4/4] sched/fair: Add document for burstable CFS bandwidth control

2021-03-15 Thread Huaixin Chang
Basic description of usage and effect for CFS Bandwidth Control Burst. Co-developed-by: Shanpei Chen Signed-off-by: Shanpei Chen Signed-off-by: Huaixin Chang --- Documentation/admin-guide/cgroup-v2.rst | 16 + Documentation/scheduler/sched-bwc.rst | 64

[PATCH v4 1/4] sched/fair: Introduce primitives for CFS bandwidth burst

2021-03-15 Thread Huaixin Chang
a group can consume in a given period is "buffer" which is equivalent to "quota" + "burst in case that this group has done enough accumulation. Co-developed-by: Shanpei Chen Signed-off-by: Shanpei Chen Signed-off-by: Huaixin Chang --- kernel/sched/core.c | 97

[PATCH v4 0/4] sched/fair: Burstable CFS bandwidth controller

2021-03-15 Thread Huaixin Chang
e present more latency statistics and handle overflow while accumulating. Huaixin Chang (4): sched/fair: Introduce primitives for CFS bandwidth burst sched/fair: Make CFS bandwidth controller burstable sched/fair: Add cfs bandwidth burst statistics sched/fair: Add document for burstable

Re: [PATCH v6 3/6] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-03-10 Thread Bae, Chang Seok
e not missing this check. Thanks, Chang

Re: [PATCH v6 3/6] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-03-10 Thread Bae, Chang Seok
On Mar 5, 2021, at 02:43, Borislav Petkov wrote: > On Sat, Feb 27, 2021 at 08:59:08AM -0800, Chang S. Bae wrote: >> Historically, signal.h defines MINSIGSTKSZ (2KB) and SIGSTKSZ (8KB), for >> use by all architectures with sigaltstack(2). Over time, the hardware state >>

Re: [PATCH v6 1/6] uapi: Define the aux vector AT_MINSIGSTKSZ

2021-03-10 Thread Bae, Chang Seok
On Mar 1, 2021, at 11:09, Borislav Petkov wrote: > On Sat, Feb 27, 2021 at 08:59:06AM -0800, Chang S. Bae wrote: >> >> diff --git a/include/uapi/linux/auxvec.h b/include/uapi/linux/auxvec.h >> index abe5f2b6581b..15be98c75174 100644 >> --- a/include/uapi/linux/aux

[PATCH v6 6/6] selftest/x86/signal: Include test cases for validating sigaltstack

2021-02-27 Thread Chang S. Bae
The test measures the kernel's signal delivery with different (enough vs. insufficient) stack sizes. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Revised test messages

[PATCH v6 0/6] x86: Improve Minimum Alternate Stack Size

2021-02-27 Thread Chang S. Bae
072-1-chang.seok@intel.com/ [10]: https://lore.kernel.org/lkml/20210203172242.29644-1-chang.seok@intel.com/ Chang S. Bae (6): uapi: Define the aux vector AT_MINSIGSTKSZ x86/signal: Introduce helpers to get the maximum signal frame size x86/elf: Support a new ELF aux vector AT_MINSIG

[PATCH v6 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-02-27 Thread Chang S. Bae
ds. While the kernel allows new source code to discover and use a sufficient alternate signal stack size, this check is still necessary to protect binaries with insufficient alternate signal stack size from data corruption. Suggested-by: Jann Horn Signed-off-by: Chang S. Bae Reviewed-by: Len Brown

[PATCH v6 4/6] selftest/sigaltstack: Use the AT_MINSIGSTKSZ aux vector if available

2021-02-27 Thread Chang S. Bae
The SIGSTKSZ constant may not represent enough stack size in some architectures as the hardware state size grows. Use getauxval(AT_MINSIGSTKSZ) to increase the stack size. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org

[PATCH v6 3/6] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-02-27 Thread Chang S. Bae
Context Switch") Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: H.J. Lu Cc: Fenghua Yu Cc: Dave Martin Cc: Michael Ellerman Cc: x...@kernel.org Cc: libc-al...@sourceware.org Cc: linux-a...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-ke

[PATCH v6 2/6] x86/signal: Introduce helpers to get the maximum signal frame size

2021-02-27 Thread Chang S. Bae
, and helper functions for the calculation to be used in a new user interface. Set max_frame_size to a system-wide worst-case value, instead of storing multiple app-specific values. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Acked-by: H.J. Lu Cc: x...@kernel.org Cc: linux-kernel

[PATCH v6 1/6] uapi: Define the aux vector AT_MINSIGSTKSZ

2021-02-27 Thread Chang S. Bae
Define the AT_MINSIGSTKSZ in generic Linux. It is already used as generic ABI in glibc's generic elf.h, and this define will prevent future namespace conflicts. In particular, x86 is also using this generic definition. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Carlos O'

Re: [PATCH v4 12/14] swiotlb: Add restricted DMA alloc/free support.

2021-02-26 Thread Claire Chang
On Fri, Feb 26, 2021 at 1:17 PM Christoph Hellwig wrote: > > On Fri, Feb 26, 2021 at 12:17:50PM +0800, Claire Chang wrote: > > Do you think I should fix this and rebase on the latest linux-next > > now? I wonder if there are more factor and clean up coming and I > >

Re: [PATCH v4 12/14] swiotlb: Add restricted DMA alloc/free support.

2021-02-25 Thread Claire Chang
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > index fd9c1bd183ac..8b77fd64199e 100644 > --- a/kernel/dma/swiotlb.c > +++ b/kernel/dma/swiotlb.c > @@ -836,6 +836,40 @@ late_initcall(swiotlb_create_default_debugfs); > #endif > > #ifdef CONFIG_DMA_RESTRICTED_POOL > +struct page *dev_s

Re: [PATCH v4 22/22] x86/fpu/xstate: Introduce boot-parameters to control state component support

2021-02-21 Thread Bae, Chang Seok
27; prefix and an extra * '\0' for termination. */ #define MAX_XSTATE_MASK_CHARS 24 /** * fpu__init_parse_early_param() - parse the xstate kernel parameters * * Parse them early because fpu__init_system() is executed before * parse_early_param(). */ static void __init fpu__init_parse_early_param(void) Thanks, Chang

[PATCH v4 17/22] x86/cpufeatures/amx: Enumerate Advanced Matrix Extension (AMX) feature bits

2021-02-21 Thread Chang S. Bae
ating-point (BF16) elements. Here we add AMX to the kernel/user ABI, by enumerating the capability. E.g., /proc/cpuinfo: amx_tile, amx_bf16, amx_int8 Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/cpufeatures.

[PATCH v4 22/22] x86/fpu/xstate: Introduce boot-parameters to control state component support

2021-02-21 Thread Chang S. Bae
is feature). Rename XFEATURE_MASK_USER_SUPPORTED to XFEATURE_MASK_USER_ENABLED to be aligned with the new parameters. While this cmdline is currently enabled only for AMX, it is intended to be easily enabled to be useful for future XSAVE-enabled features. Signed-off-by: Chang S. Bae Reviewed-

[PATCH v4 21/22] x86/fpu/xstate: Support dynamic user state in the signal handling path

2021-02-21 Thread Chang S. Bae
in the signal handler that the signal frame excludes AMX data when the signaled thread has initialized AMX state. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-kselft...@vger.kernel.org --- Changes from v3: * Removed 'no fu

[PATCH v4 16/22] x86/fpu/xstate: Extend the table to map state components with features

2021-02-21 Thread Chang S. Bae
be gaps in the XCR0 feature bit numbers. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v1: * Rebased on the upstream kernel (5.10) --- arch/x86/kernel/fpu/xstate.c | 41

[PATCH v4 20/22] selftest/x86/amx: Include test cases for the AMX state management

2021-02-21 Thread Chang S. Bae
d has initialized its AMX state. Collect the test cases of validating those operations together, as they share some common setup for the AMX state. These test cases do not depend on AMX compiler support, as they employ userspace-XSAVE directly to access AMX state. Signed-off-by: Chang S. Bae Review

[PATCH v4 08/22] x86/fpu/xstate: Convert the struct fpu 'state' field to a pointer

2021-02-21 Thread Chang S. Bae
. Add a new field to represent the embedded buffer. Every child process will set the pointer on its creation. And the initial task sets it before dealing with soft FPU. No functional change. Suggested-by: Borislav Petkov Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.

[PATCH v4 15/22] x86/fpu/xstate: Support ptracer-induced xstate buffer expansion

2021-02-21 Thread Chang S. Bae
ptrace() may update xstate data before the target task has taken an XFD fault and expanded the xstate buffer. Detect this case and allocate a sufficient buffer to support the request. Also, disable the (now unnecessary) associated first-use fault. Signed-off-by: Chang S. Bae Reviewed-by: Len

[PATCH v4 13/22] x86/fpu/xstate: Update the xstate context copy function to support dynamic states

2021-02-21 Thread Chang S. Bae
helpers to find a component's offset accordingly. When copying an initial value, explicitly check the init_fpstate coverage. If not found, reset the memory in the destination. Otherwise, copy values from init_fpstate. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org C

[PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-02-21 Thread Chang S. Bae
abled() xfirstuse_not_detected() The #NM handler induces the xstate buffer expansion to save the first-used states. The XFD feature is enabled only for the compacted format. If the kernel uses the standard format, the buffer has to be always enough for all the states. Signed-off-by: Chang S. Bae Reviewed-by

[PATCH v4 07/22] x86/fpu/xstate: Calculate and remember dynamic xstate buffer sizes

2021-02-21 Thread Chang S. Bae
embedded buffer size by excluding the dynamic user states from the maximum size. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Updated the changelog. (Borislav Petkov) * Updated the code comment. (Borislav Petkov

[PATCH v4 19/22] x86/fpu/amx: Enable the AMX feature in 64-bit mode

2021-02-21 Thread Chang S. Bae
In 64-bit mode, include the AMX state components in XFEATURE_MASK_USER_SUPPORTED. The XFD feature will be used to dynamically expand the xstate per-task buffer on the first use. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch

[PATCH v4 12/22] x86/fpu/xstate: Update the xstate buffer address finder to support dynamic states

2021-02-21 Thread Chang S. Bae
r the address finder. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Added the function description in the kernel-doc style. (Borislav Petkov) * Removed 'no functional change' in the changelog. (Borislav Petkov

[PATCH v4 06/22] x86/fpu/xstate: Add new variables to indicate dynamic xstate buffer size

2021-02-21 Thread Chang S. Bae
user buffer size. No functional change. Those sizes have no difference, as the buffer is not dynamic yet. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v3: * Added as a new patch to add the

[PATCH v4 05/22] x86/fpu/xstate: Add a new variable to indicate dynamic user states

2021-02-21 Thread Chang S. Bae
witch. The states are named as 'dynamic' supervisor states. Some define and helper are not named with dynamic supervisor states, so rename them. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes fr

[PATCH v4 11/22] x86/fpu/xstate: Update the xstate save function to support dynamic states

2021-02-21 Thread Chang S. Bae
Extend copy_xregs_to_kernel() to receive a mask argument of which states to save, in preparation for dynamic user state handling. Update KVM to set a valid fpu->state_mask, so it can continue to share with the core code. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org

[PATCH v4 01/22] x86/fpu/xstate: Modify the initialization helper to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
configure XCOMP_BV for the compacted format. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v3: * Updated the changelog. (Borislav Petkov) * Updated the function comment to use

[PATCH v4 18/22] x86/fpu/amx: Define AMX state components and have it used for boot-time checks

2021-02-21 Thread Chang S. Bae
. The first implementation supports 8KB. Check the XTILEDATA state size dynamically. The feature introduces the new tile register, TMM. Define one register struct only and read the number of registers from CPUID. Cross-check the overall size with CPUID again. Signed-off-by: Chang S. Bae Reviewed-by

[PATCH v4 10/22] x86/fpu/xstate: Define the scope of the initial xstate data

2021-02-21 Thread Chang S. Bae
having initial data with zeros. Expand copy_xregs_to_kernel_booting() to receive a mask argument of which states to save. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Removed the helper functions. (Borislav Petkov

[PATCH v4 02/22] x86/fpu/xstate: Modify state copy helpers to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
Have all the functions copying xstate take a struct fpu * pointer in preparation for dynamic state buffer support. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Updated the changelog

[PATCH v4 03/22] x86/fpu/xstate: Modify address finders to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
Have all the functions finding xstate address take a struct fpu * pointer in preparation for dynamic state buffer support. init_fpstate is a special case, which is indicated by a null pointer parameter to get_xsave_addr() and __raw_xsave_addr(). No functional change. Signed-off-by: Chang S. Bae

[PATCH v4 09/22] x86/fpu/xstate: Introduce helpers to manage the xstate buffer dynamically

2021-02-21 Thread Chang S. Bae
new field and helper to initialize the buffer. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Updated code comments. (Borislav Petkov) * Used vzalloc() instead of vmalloc() with memset(). (Borislav Petkov) * Removed the

[PATCH v4 04/22] x86/fpu/xstate: Modify the context restore helper to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
Have the function restoring xstate take a struct fpu * pointer in preparation for dynamic state buffer support. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v3: * Updated

[PATCH v4 00/22] x86: Support Intel Advanced Matrix Extensions

2021-02-21 Thread Chang S. Bae
https://lore.kernel.org/lkml/20201001203913.9125-1-chang.seok@intel.com/ [5]: https://lore.kernel.org/lkml/20201119233257.2939-1-chang.seok@intel.com/ [6]: https://lore.kernel.org/lkml/20201223155717.19556-1-chang.seok@intel.com/ Chang S. Bae (22): x86/fpu/xstate: Modify the initiali

Re: [PATCH v3 11/21] x86/fpu/xstate: Update xstate buffer address finder to support dynamic xstate

2021-02-19 Thread Bae, Chang Seok
On Feb 19, 2021, at 07:00, Borislav Petkov wrote: > On Wed, Dec 23, 2020 at 07:57:07AM -0800, Chang S. Bae wrote: >> >> >> +/* >> + * Available once those arrays for the offset, size, and alignment info are >> set up, >> + * by setup_xstate_features().

Re: [PATCH v3 09/21] x86/fpu/xstate: Introduce wrapper functions to organize xstate buffer access

2021-02-09 Thread Bae, Chang Seok
On Feb 8, 2021, at 04:33, Borislav Petkov wrote: > On Wed, Dec 23, 2020 at 07:57:05AM -0800, Chang S. Bae wrote: >> The struct fpu includes two (possible) xstate buffers -- fpu->state and >> fpu->state_ptr. Instead of open code for accessing one of them, provide a >&g

Re: [PATCH v3 10/21] x86/fpu/xstate: Update xstate save function to support dynamic xstate

2021-02-09 Thread Bae, Chang Seok
On Feb 8, 2021, at 04:33, Borislav Petkov wrote: > On Wed, Dec 23, 2020 at 07:57:06AM -0800, Chang S. Bae wrote: >> copy_xregs_to_kernel() used to save all user states in a kernel buffer. >> When the dynamic user state is enabled, it becomes conditional which state >> to

Re: [PATCH v3 08/21] x86/fpu/xstate: Define the scope of the initial xstate data

2021-02-09 Thread Bae, Chang Seok
On Feb 9, 2021, at 04:49, Borislav Petkov wrote: > On Mon, Feb 08, 2021 at 06:53:23PM +, Bae, Chang Seok wrote: > Yours does. So drop it from this one and from all the other patches as > it is causing more confusion than it is trying to dispel. Okay. >> I think they are

  1   2   3   4   5   6   7   8   9   10   >