Skip to content

[WIP] [Deepin-Kernel-SIG] [linux 6.6-y] deepin: KABI: reserve some space for kABI from Anolis #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: linux-6.6.y
Choose a base branch
from

Conversation

Avenger-285714
Copy link
Collaborator

@Avenger-285714 Avenger-285714 commented Jun 5, 2025

Reserve some space for kABI.

Link: https://gitee.com/anolis/cloud-kernel/pulls/3764

Summary by Sourcery

Reserve padding for kernel ABI (kABI) compatibility by adding DEEPIN_KABI_RESERVE entries and including deepin_kabi.h across scheduler, BPF, network, block, and numerous other subsystems to align with Anolis kABI requirements

Enhancements:

  • Introduce DEEPIN_KABI_RESERVE markers in various kernel structures to allocate reserved fields for future ABI extensions
  • Add #include <linux/deepin_kabi.h> in headers and sources where reserves are applied

@Avenger-285714 Avenger-285714 requested a review from Copilot June 5, 2025 17:11
Copy link

sourcery-ai bot commented Jun 5, 2025

Reviewer's Guide

This PR augments the kernel’s public ABI by injecting reserved padding slots (via the DEEPIN_KABI_RESERVE macro) and including the new deepin_kabi header into a broad range of core data structures to pre-allocate space for future kernel-ABI extensions (sourced from Anolis).

Updated Class Diagram for struct rt_bandwidth

classDiagram
  class rt_bandwidth {
    +DEEPIN_KABI_RESERVE(3)
    +DEEPIN_KABI_RESERVE(4)
  }
Loading

Updated Class Diagram for struct task_group

classDiagram
  class task_group {
    +DEEPIN_KABI_RESERVE(1)
    +DEEPIN_KABI_RESERVE(2)
    +DEEPIN_KABI_RESERVE(3)
    +DEEPIN_KABI_RESERVE(4)
    +DEEPIN_KABI_RESERVE(5)
    +DEEPIN_KABI_RESERVE(6)
    +DEEPIN_KABI_RESERVE(7)
    +DEEPIN_KABI_RESERVE(8)
  }
Loading

Updated Class Diagram for struct net_device_ops

classDiagram
  class net_device_ops {
    +DEEPIN_KABI_RESERVE(9)
    +DEEPIN_KABI_RESERVE(10)
    +DEEPIN_KABI_RESERVE(11)
    +DEEPIN_KABI_RESERVE(12)
    +DEEPIN_KABI_RESERVE(13)
    +DEEPIN_KABI_RESERVE(14)
    +DEEPIN_KABI_RESERVE(15)
    +DEEPIN_KABI_RESERVE(16)
  }
Loading

Updated Class Diagram for struct module

classDiagram
  class module {
    +DEEPIN_KABI_RESERVE(1)
    +DEEPIN_KABI_RESERVE(2)
    +DEEPIN_KABI_RESERVE(3)
    +DEEPIN_KABI_RESERVE(4)
  }
Loading

File-Level Changes

Change Details Files
Added deepin_kabi include
  • Inserted #include <linux/deepin_kabi.h> into key headers (sched.h, bpf.h, netdevice.h, blk-mq.h, fs.h, etc.)
kernel/sched/sched.h
include/linux/sched.h
include/linux/bpf.h
include/linux/netdevice.h
include/linux/blk-mq.h
include/linux/fs.h
... (many more)
Injected ABI padding in scheduling structs
  • Appended multiple DEEPIN_KABI_RESERVE(n) lines to rt_bandwidth, dl_bw, cfs_bandwidth, task_group, cfs_rq, rt_rq, dl_rq, root_domain, rq, sched_group_capacity, sched_group, sched_class, etc.
kernel/sched/sched.h
include/linux/sched.h
Reserved slots in networking and namespace types
  • Added DEEPIN_KABI_RESERVE in netns_smc, netns_sctp, netns_unix, inet6_dev, neigh_table, netdev_rx_queue, xdp_frame, flow_offload, sock_reuseport, and various netfilter/nf_conntrack structures
include/net/netns/smc.h
include/net/netns/sctp.h
include/net/netns/unix.h
include/net/if_inet6.h
include/net/neighbour.h
include/net/netdev_rx_queue.h
include/net/xdp.h
include/net/flow_offload.h
include/net/sock_reuseport.h
include/net/netfilter/nf_conntrack_common.h
Padded BPF and inner verifier types
  • Appended reserve macros in bpf_map_ops, bpf_map, bpf_insn_access_aux, btf_func_model, bpf_ksym, bpf_tramp_image, bpf_trampoline, bpf_prog_aux, bpf_prog, bpf_link_ops, bpf_iter_aux_info
include/linux/bpf.h
include/linux/bpf_verifier.h
Reserved space in block and BIO types
  • Inserted padding in bio_integrity_payload, bio_set, blk_integrity, gendisk, queue_limits, request_queue, blk_plug, blk_plug_cb, blk_mq_tags, blk_mq_hw_ctx, blk_mq_tag_set, blk_mq_queue_data, blk_mq_ops
include/linux/bio.h
include/linux/blkdev.h
include/include/linux/blk-mq.h
block/blk-cgroup.h
Injected padding across FS and VFS interfaces
  • Added reserve macros to file_operations, inode_operations, super_operations, file_system_type, dentry_operations, export_operations, filelock, fwnode_handle, xattr_handler
include/linux/fs.h
include/linux/dcache.h
include/linux/sysfs.h
include/linux/exportfs.h
include/linux/filelock.h
include/linux/fwnode.h
include/linux/xattr.h
Reserved slots in device, DMA and PCI subsystems
  • Applied DEEPIN_KABI_RESERVE in struct device, pci_dev, pci_bus, dma_map_ops, dma-fence, iommu_ops, irq_domain, irq_chip, irq_data, irq_common_data
include/linux/device.h
include/linux/pci.h
include/linux/irq.h
include/linux/irqdomain.h
include/linux/irqchip.h
include/linux/dma-map-ops.h
Padded various driver and arch structures
  • Injected reserve macros in ptp_clock, dw_pcie, pci_epf, pcie-designware, kvm_host, acpi_bus, drm, scsi, ubifs, etc.
drivers/ptp/ptp_private.h
drivers/pci/controller/dwc/pcie-designware.h
include/arch/*/kvm_host.h
include/acpi/acpi_bus.h
include/drm/*
include/scsi/*
fs/ubifs/ubifs.h
Aligned sk_buff to cacheline
  • Added 4 reserve slots in struct sk_buff with comment to maintain 256-byte size under SLAB_HWCACHE_ALIGN
include/linux/skbuff.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from avenger-285714. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request reserves additional space for kernel ABI (kABI) compatibility in various subsystems. The key changes are the addition of DEEPIN_KABI_RESERVE macros in multiple header files to allocate reserved space, ensuring future backward compatibility and extension.

Reviewed Changes

Copilot reviewed 170 out of 170 changed files in this pull request and generated no comments.

Show a summary per file
File Description
include/drm/drm_modeset_helper_vtables.h Added reserve space for kABI in drm_mode_config_helper_funcs.
include/drm/drm_crtc.h Added reserve space for kABI in drm_crtc_state and drm_crtc.
include/drm/drm_connector.h Added several DEEPIN_KABI_RESERVE macros to reserve kABI slots.
include/drm/drm_client.h Added reserve space for kABI in drm_client_buffer.
include/drm/drm_atomic.h Added reserve space for kABI in private state-related structures.
include/acpi/acpi_bus.h Added reserve space for kABI in acpi_device_power structure.
fs/ubifs/ubifs.h Added reserve space for kABI in ubifs_inode and ubifs_info.
fs/ubifs/debug.h Added include and reserve space for kABI.
fs/mount.h Added include and reserve space for kABI in mount structure.
fs/eventfd.c Added reserve space for kABI in eventfd_ctx.
drivers/ptp/ptp_private.h Added reserve space for kABI in ptp_clock structure.
drivers/pci/controller/dwc/pcie-designware.h Added reserve space for kABI in several PCIe-related structures.
drivers/block/brd.c Added reserve space for kABI in brd_device.
block/elevator.h Added reserve space for kABI in elevator operations and type structs.
block/blk-mq.h Added reserve space for kABI in blk_mq_alloc_data.
block/blk-cgroup.h Added reserve space for kABI in multiple blk cgroup structures.
arch/x86/include/asm/kvm_host.h Added reserve space for kABI in kvm_arch.
arch/x86/include/asm/kprobes.h Added reserve space for kABI in arch_specific_insn.
arch/arm64/include/asm/probes.h Added include and reserve space for kABI in arch_specific_insn.
arch/arm64/include/asm/kvm_host.h Added reserve space for kABI in kvm_arch.
Comments suppressed due to low confidence (3)

include/drm/drm_connector.h:325

  • Multiple consecutive DEEPIN_KABI_RESERVE macros are added here. Consider adding an inline comment to explain the purpose of these reserved fields for future maintainers.
DEEPIN_KABI_RESERVE(1)

fs/ubifs/ubifs.h:1529

  • The structure includes several consecutive DEEPIN_KABI_RESERVE macros. Please add a comment explaining the reserved slots to improve code clarity and maintainability.
DEEPIN_KABI_RESERVE(1)

block/blk-cgroup.h:53

  • Consider documenting the intent behind these multiple DEEPIN_KABI_RESERVE macros so that future developers understand the reserved space and its intended future use.
DEEPIN_KABI_RESERVE(1)

@Avenger-285714 Avenger-285714 requested a review from opsiff June 5, 2025 17:12
@Avenger-285714
Copy link
Collaborator Author

deepin没有使能CONFIG_DEEPIN_KABI_RESERVE配置项。经LLVM19工具链手工检查,开启该配置后可编译通过。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Avenger-285714 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -22,5 +22,38 @@ struct netns_smc {
int sysctl_smcr_testlink_time;
int sysctl_wmem;
int sysctl_rmem;

DEEPIN_KABI_RESERVE(1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider replacing the 32 individual DEEPIN_KABI_RESERVE macros with a single array macro to reserve space.

/* In a common header (e.g. deepin_kabi.h), add: */

#define DEEPIN_KABI_RESERVE_ARRAY(cnt) \
    __u64 __deepin_kabi_reserved[(cnt)]


/* Then, in your struct, replace the 32 lines with one: */

struct netns_smc {
    bool               limit_smc_hs;
#ifdef CONFIG_SYSCTL
    struct ctl_table_header *smc_hdr;
#endif
    unsigned int       sysctl_autocorking_size;
    unsigned int       sysctl_smcr_buf_type;
    int                sysctl_smcr_testlink_time;
    int                sysctl_wmem;
    int                sysctl_rmem;

    /* collapse 32 individual DEEPIN_KABI_RESERVE(N) slots */
    DEEPIN_KABI_RESERVE_ARRAY(32);
};

This preserves the same reserved space, dramatically cuts boilerplate, and still allows you to expand one of those slots later if required.

@Avenger-285714 Avenger-285714 changed the title [Deepin-Kernel-SIG] [linux 6.6-y] deepin: KABI: reserve some space for kABI from Anolis [WIP] [Deepin-Kernel-SIG] [linux 6.6-y] deepin: KABI: reserve some space for kABI from Anolis Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants