Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'bpf-s390-implement-get_preempt_count'

Ilya Leoshkevich says:

====================
bpf/s390: Implement get_preempt_count()

This series adds get_preempt_count() BPF implementation for s390.
On s390 preempt_count lives in lowcore: a per-cpu data structure
mapped at virtual address 0 or 0x70000 depending on the kernel
command line.

Patch 1 adds a kfunc to obtain lowcore address.
Patch 2 is the implementation that delegates to it.
====================

Link: https://patch.msgid.link/20260217160813.100855-1-iii@linux.ibm.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+28
+2
arch/s390/kernel/Makefile
··· 80 80 81 81 obj-$(CONFIG_TRACEPOINTS) += trace.o 82 82 83 + obj-$(CONFIG_BPF_SYSCALL) += bpf.o 84 + 83 85 # vdso 84 86 obj-y += vdso/
+12
arch/s390/kernel/bpf.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <asm/lowcore.h> 3 + #include <linux/btf.h> 4 + 5 + __bpf_kfunc_start_defs(); 6 + 7 + __bpf_kfunc struct lowcore *bpf_get_lowcore(void) 8 + { 9 + return get_lowcore(); 10 + } 11 + 12 + __bpf_kfunc_end_defs();
+3
kernel/bpf/helpers.c
··· 4578 4578 BTF_ID_FLAGS(func, bpf_verify_pkcs7_signature, KF_SLEEPABLE) 4579 4579 #endif 4580 4580 #endif 4581 + #ifdef CONFIG_S390 4582 + BTF_ID_FLAGS(func, bpf_get_lowcore) 4583 + #endif 4581 4584 BTF_KFUNCS_END(generic_btf_ids) 4582 4585 4583 4586 static const struct btf_kfunc_id_set generic_kfunc_set = {
+11
tools/testing/selftests/bpf/bpf_experimental.h
··· 627 627 int softirq_disable_cnt; 628 628 } __attribute__((preserve_access_index)); 629 629 630 + #ifdef bpf_target_s390 631 + extern struct lowcore *bpf_get_lowcore(void) __weak __ksym; 632 + #endif 633 + 630 634 static inline int get_preempt_count(void) 631 635 { 632 636 #if defined(bpf_target_x86) ··· 651 647 return bpf_get_current_task_btf()->thread_info.preempt.count; 652 648 #elif defined(bpf_target_powerpc) 653 649 return bpf_get_current_task_btf()->thread_info.preempt_count; 650 + #elif defined(bpf_target_s390) 651 + return bpf_get_lowcore()->preempt_count; 654 652 #endif 655 653 return 0; 656 654 } ··· 662 656 * * x86 663 657 * * arm64 664 658 * * powerpc64 659 + * * s390x 665 660 */ 666 661 static inline int bpf_in_interrupt(void) 667 662 { ··· 683 676 * * x86 684 677 * * arm64 685 678 * * powerpc64 679 + * * s390x 686 680 */ 687 681 static inline int bpf_in_nmi(void) 688 682 { ··· 695 687 * * x86 696 688 * * arm64 697 689 * * powerpc64 690 + * * s390x 698 691 */ 699 692 static inline int bpf_in_hardirq(void) 700 693 { ··· 707 698 * * x86 708 699 * * arm64 709 700 * * powerpc64 701 + * * s390x 710 702 */ 711 703 static inline int bpf_in_serving_softirq(void) 712 704 { ··· 727 717 * * x86 728 718 * * arm64 729 719 * * powerpc64 720 + * * s390x 730 721 */ 731 722 static inline int bpf_in_task(void) 732 723 {