Skip to content

powerpc: Define eligible functions as __init

Nick Child linuxppc-dev 2 versions Applied

Status from this message: Applied to powerpc/next.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest20 patches 3 repliesApplied
  2. v120 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- add __init in prototypes right before the funtion name instead of at the end.
- respond to ./scripts/checkpatch feedback
- reference the related github issue in cover letter
- fix date in cover letter
- rebase onto latest merge

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/20powerpc/kernel: Add __init attribute to eligible functionsarch/powerpc/include/asm/btext.h arch/powerpc/include/asm/eeh.h arch/powerpc/include/asm/fadump-internal.h +21 more+69 -680 replies
2/20powerpc/lib: Add __init attribute to eligible functionsarch/powerpc/include/asm/setup.h arch/powerpc/lib/code-patching.c arch/powerpc/lib/feature-fixups.c+15 -150 replies
3/20powerpc/mm: Add __init attribute to eligible functionsarch/powerpc/include/asm/hugetlb.h arch/powerpc/include/asm/mmu_context.h arch/powerpc/mm/book3s32/mmu.c +10 more+20 -200 replies
4/20powerpc/perf: Add __init attribute to eligible functionsarch/powerpc/include/asm/perf_event_server.h arch/powerpc/perf/core-book3s.c arch/powerpc/perf/generic-compat-pmu.c +9 more+20 -200 replies
5/20powerpc/sysdev: Add __init attribute to eligible functionsarch/powerpc/include/asm/cpm2.h arch/powerpc/include/asm/i8259.h arch/powerpc/include/asm/ipic.h +21 more+40 -400 replies
6/20powerpc/xmon: Add __init attribute to eligible functionsarch/powerpc/include/asm/xmon.h arch/powerpc/xmon/xmon.c+2 -20 replies
7/20powerpc/cell: Add __init attribute to eligible functionsarch/powerpc/platforms/cell/cbe_regs.c arch/powerpc/platforms/cell/iommu.c arch/powerpc/platforms/cell/spu_base.c +2 more+20 -200 replies
8/20powerpc/chrp: Add __init attribute to eligible functionsarch/powerpc/platforms/chrp/pegasos_eth.c+1 -10 replies
9/20powerpc/pasemi: Add __init attribute to eligible functionsarch/powerpc/platforms/pasemi/msi.c arch/powerpc/platforms/pasemi/pasemi.h arch/powerpc/platforms/pasemi/pci.c +2 more+5 -50 replies
10/20powerpc/powermac: Add __init attribute to eligible functionsarch/powerpc/include/asm/smu.h arch/powerpc/include/asm/udbg.h arch/powerpc/platforms/powermac/feature.c +5 more+11 -110 replies
11/20powerpc/powernv: Add __init attribute to eligible functionsarch/powerpc/include/asm/cpuidle.h arch/powerpc/include/asm/opal.h arch/powerpc/platforms/powernv/idle.c +12 more+28 -280 replies
12/20powerpc/pseries: Add __init attribute to eligible functionsarch/powerpc/include/asm/book3s/64/mmu.h arch/powerpc/include/asm/iommu.h arch/powerpc/include/asm/setup.h +8 more+18 -180 replies
13/20powerpc/ps3: Add __init attribute to eligible functionsarch/powerpc/platforms/ps3/gelic_udbg.c arch/powerpc/platforms/ps3/mm.c arch/powerpc/platforms/ps3/os-area.c +4 more+24 -240 replies
14/20powerpc/4xx: Add __init attribute to eligible functionsarch/powerpc/platforms/4xx/cpm.c arch/powerpc/platforms/4xx/pci.c+3 -30 replies
15/20powerpc/44x: Add __init attribute to eligible functionsarch/powerpc/platforms/44x/fsp2.c+2 -20 replies
16/20powerpc/embedded6xx: Add __init attribute to eligible functionsarch/powerpc/platforms/embedded6xx/hlwd-pic.c arch/powerpc/platforms/embedded6xx/hlwd-pic.h arch/powerpc/platforms/embedded6xx/holly.c +2 more+7 -70 replies
17/20powerpc/83xx: Add __init attribute to eligible functionsarch/powerpc/platforms/83xx/km83xx.c arch/powerpc/platforms/83xx/mpc834x_mds.c arch/powerpc/platforms/83xx/mpc837x_mds.c +3 more+10 -100 replies
18/20powerpc/85xx: Add __init attribute to eligible functionsarch/powerpc/platforms/85xx/ge_imp3a.c arch/powerpc/platforms/85xx/mpc85xx_cds.c arch/powerpc/platforms/85xx/socrates_fpga_pic.c +2 more+6 -60 replies
19/20powerpc/512x: Add __init attribute to eligible functionsarch/powerpc/platforms/512x/clock-commonclk.c arch/powerpc/platforms/512x/mpc512x.h arch/powerpc/platforms/512x/mpc512x_shared.c+30 -300 replies
20/20cuda/pmu: Make find_via_cuda/pmu init functionsarch/powerpc/platforms/powermac/setup.c include/linux/cuda.h include/linux/pmu.h+4 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/20] powerpc: Define eligible functions as __init

Hello all,

This patchset focuses on redefining/declaring functions that could be labeled with the macro __init. From my understanding, an initialization function is one which is only needed during the initial phases of booting, after which it's resources can be freed. I figure that any function which is only called by other initialization functions may also be labeled as an initialization function. There are several (mostly static) functions which can and should be labeled as __init. I created some scripts to help identify these functions. It scans all functions defined in arch/powerpc and, if it is only called by functions with the __init attribute, it will go on to adjust the prototype and definition to include the __init declaration. This patchset hopes to solve related issue #282:
https://github.com/linuxppc/issues/issues/282

Some notes about the scripts:
1. Trying to handle things like functions assigned to macros and function pointers proved to be a bit too complicated to track. I ended up just halting the investigation of these functions. In the future, I would like to be able to attempt to __init them but for now we leave them alone.

2. The proper syntax for adding the __init macro is followed as it is defined in include/linux/init.h.

3. There are some odd looking functions that look something like:
char *__init foo(.... I have found that this happens in many other places in the kernel source prior to running the scripts. Additionally, after running the scripts. I have successfully built all powerpc defconfigs without error. For these reasons, I assume the odd syntax is valid but I am interested in other opinions on this.

5. I have run my scripts on the Dec 14, 2021 merge branch

      (specifically 798527287598)

After running my script for 3 rounds, they have identified about 250 functions so I tried to break the patches up into related platforms and subdirectories. There are only two functions with a prototype outside of arch/powerpc, these are find_via_cuda and find_via_pmu. I put those in their own patch.

Other than building all the ppc defconfigs, I have tested the changes by building kernels with and without the patches using defconfigs ppc64le_guest, powernv and pseries_le. There were no size differences reported in the boot logs. However, when using readelf -t we see the following differences in the size of the .text section:
ppc64le_guest -> .text decreased in size by 12.8k, init.text unchanged powernv -> .text decreased in size by 7.7k, init.text unchanged pseries_le -> .text decreased in size by 9.6k, init.text increased 65.5k

I figured the size differences (or lack of) in .init.text might have something to do with the requirement that the .init.text "section ends on a page boundary", as described in arch/powerpc/kernel/vmlinux.lds.S.

I am excited to say this is my first attempt at kernel development. I know this patchset is in no way important but I figured it was a good starting point. Please let me know if there is anything I am doing wrong or if I can do anything to help meet the kernel contribution guidelines.

Special thanks to Daniel Axtens for mentoring me and helping me get my first patchset out!

Changes in v2:
- add __init in prototypes right before the funtion name instead of at the end.
- respond to ./scripts/checkpatch feedback
- reference the related github issue in cover letter
- fix date in cover letter
- rebase onto latest merge
v1:
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=277093&state=

Nick Child (20):
powerpc/kernel: Add __init attribute to eligible functions powerpc/lib: Add __init attribute to eligible functions powerpc/mm: Add __init attribute to eligible functions powerpc/perf: Add __init attribute to eligible functions powerpc/sysdev: Add __init attribute to eligible functions powerpc/xmon: Add __init attribute to eligible functions powerpc/cell: Add __init attribute to eligible functions powerpc/chrp: Add __init attribute to eligible functions powerpc/pasemi: Add __init attribute to eligible functions powerpc/powermac: Add __init attribute to eligible functions powerpc/powernv: Add __init attribute to eligible functions powerpc/pseries: Add __init attribute to eligible functions powerpc/ps3: Add __init attribute to eligible functions powerpc/4xx: Add __init attribute to eligible functions powerpc/44x: Add __init attribute to eligible functions powerpc/embedded6xx: Add __init attribute to eligible functions powerpc/83xx: Add __init attribute to eligible functions powerpc/85xx: Add __init attribute to eligible functions powerpc/512x: Add __init attribute to eligible functions cuda/pmu: Make find_via_cuda/pmu init functions

 arch/powerpc/include/asm/book3s/64/mmu.h      |  2 +-
 arch/powerpc/include/asm/btext.h              | 10 ++--
 arch/powerpc/include/asm/cpm2.h               |  6 +--
 arch/powerpc/include/asm/cpuidle.h            |  2 +-
 arch/powerpc/include/asm/eeh.h                |  2 +-
 arch/powerpc/include/asm/fadump-internal.h    |  6 +--
 arch/powerpc/include/asm/hugetlb.h            |  2 +-
 arch/powerpc/include/asm/i8259.h              |  2 +-
 arch/powerpc/include/asm/iommu.h              |  2 +-
 arch/powerpc/include/asm/ipic.h               |  2 +-
 arch/powerpc/include/asm/kexec.h              |  2 +-
 arch/powerpc/include/asm/kvm_guest.h          |  2 +-
 arch/powerpc/include/asm/mmu_context.h        |  2 +-
 arch/powerpc/include/asm/mpic.h               |  2 +-
 arch/powerpc/include/asm/opal.h               |  2 +-
 arch/powerpc/include/asm/pci.h                |  2 +-
 arch/powerpc/include/asm/perf_event_server.h  |  2 +-
 arch/powerpc/include/asm/setup.h              |  8 +--
 arch/powerpc/include/asm/smu.h                |  2 +-
 arch/powerpc/include/asm/udbg.h               | 10 ++--
 arch/powerpc/include/asm/xics.h               |  4 +-
 arch/powerpc/include/asm/xmon.h               |  2 +-
 arch/powerpc/kernel/btext.c                   | 12 ++---
 arch/powerpc/kernel/dt_cpu_ftrs.c             |  2 +-
 arch/powerpc/kernel/eeh_cache.c               |  2 +-
 arch/powerpc/kernel/fadump.c                  | 18 +++----
 arch/powerpc/kernel/nvram_64.c                |  6 +--
 arch/powerpc/kernel/pci-common.c              |  2 +-
 arch/powerpc/kernel/pci_32.c                  |  4 +-
 arch/powerpc/kernel/prom.c                    |  4 +-
 arch/powerpc/kernel/prom_init.c               | 12 ++---
 arch/powerpc/kernel/rtasd.c                   |  6 +--
 arch/powerpc/kernel/security.c                |  4 +-
 arch/powerpc/kernel/setup_64.c                |  2 +-
 arch/powerpc/kernel/smp.c                     |  5 +-
 arch/powerpc/kernel/sysfs.c                   | 10 ++--
 arch/powerpc/kernel/udbg_16550.c              | 10 ++--
 arch/powerpc/kexec/core.c                     |  2 +-
 arch/powerpc/lib/code-patching.c              |  2 +-
 arch/powerpc/lib/feature-fixups.c             | 26 +++++-----
 arch/powerpc/mm/book3s32/mmu.c                |  2 +-
 arch/powerpc/mm/book3s64/hash_utils.c         |  6 +--
 arch/powerpc/mm/book3s64/hugetlbpage.c        |  2 +-
 arch/powerpc/mm/book3s64/mmu_context.c        |  2 +-
 arch/powerpc/mm/book3s64/pkeys.c              |  2 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c      |  4 +-
 arch/powerpc/mm/nohash/44x.c                  |  4 +-
 arch/powerpc/mm/nohash/fsl_book3e.c           |  2 +-
 arch/powerpc/mm/nohash/tlb.c                  |  4 +-
 arch/powerpc/mm/numa.c                        |  6 +--
 arch/powerpc/mm/ptdump/ptdump.c               |  2 +-
 arch/powerpc/perf/core-book3s.c               |  2 +-
 arch/powerpc/perf/generic-compat-pmu.c        |  2 +-
 arch/powerpc/perf/internal.h                  | 18 +++----
 arch/powerpc/perf/power10-pmu.c               |  2 +-
 arch/powerpc/perf/power5+-pmu.c               |  2 +-
 arch/powerpc/perf/power5-pmu.c                |  2 +-
 arch/powerpc/perf/power6-pmu.c                |  2 +-
 arch/powerpc/perf/power7-pmu.c                |  2 +-
 arch/powerpc/perf/power8-pmu.c                |  2 +-
 arch/powerpc/perf/power9-pmu.c                |  2 +-
 arch/powerpc/perf/ppc970-pmu.c                |  2 +-
 arch/powerpc/platforms/44x/fsp2.c             |  4 +-
 arch/powerpc/platforms/4xx/cpm.c              |  4 +-
 arch/powerpc/platforms/4xx/pci.c              |  2 +-
 arch/powerpc/platforms/512x/clock-commonclk.c | 52 +++++++++----------
 arch/powerpc/platforms/512x/mpc512x.h         |  4 +-
 arch/powerpc/platforms/512x/mpc512x_shared.c  |  4 +-
 arch/powerpc/platforms/83xx/km83xx.c          |  2 +-
 arch/powerpc/platforms/83xx/mpc834x_mds.c     |  2 +-
 arch/powerpc/platforms/83xx/mpc837x_mds.c     |  2 +-
 arch/powerpc/platforms/83xx/mpc837x_rdb.c     |  2 +-
 arch/powerpc/platforms/83xx/mpc83xx.h         |  6 +--
 arch/powerpc/platforms/83xx/usb.c             |  6 +--
 arch/powerpc/platforms/85xx/ge_imp3a.c        |  2 +-
 arch/powerpc/platforms/85xx/mpc85xx_cds.c     |  2 +-
 .../platforms/85xx/socrates_fpga_pic.c        |  2 +-
 .../platforms/85xx/socrates_fpga_pic.h        |  2 +-
 arch/powerpc/platforms/85xx/xes_mpc85xx.c     |  4 +-
 arch/powerpc/platforms/cell/cbe_regs.c        |  2 +-
 arch/powerpc/platforms/cell/iommu.c           | 14 ++---
 arch/powerpc/platforms/cell/spu_base.c        |  6 +--
 arch/powerpc/platforms/cell/spu_manage.c      | 16 +++---
 arch/powerpc/platforms/cell/spufs/inode.c     |  2 +-
 arch/powerpc/platforms/chrp/pegasos_eth.c     |  2 +-
 arch/powerpc/platforms/embedded6xx/hlwd-pic.c |  4 +-
 arch/powerpc/platforms/embedded6xx/hlwd-pic.h |  2 +-
 arch/powerpc/platforms/embedded6xx/holly.c    |  2 +-
 .../platforms/embedded6xx/usbgecko_udbg.c     |  4 +-
 arch/powerpc/platforms/embedded6xx/wii.c      |  2 +-
 arch/powerpc/platforms/pasemi/msi.c           |  2 +-
 arch/powerpc/platforms/pasemi/pasemi.h        |  2 +-
 arch/powerpc/platforms/pasemi/pci.c           |  2 +-
 arch/powerpc/platforms/pasemi/setup.c         |  2 +-
 arch/powerpc/platforms/powermac/feature.c     |  2 +-
 arch/powerpc/platforms/powermac/nvram.c       |  2 +-
 arch/powerpc/platforms/powermac/pfunc_base.c  |  6 +--
 arch/powerpc/platforms/powermac/setup.c       |  6 +--
 arch/powerpc/platforms/powermac/smp.c         |  4 +-
 arch/powerpc/platforms/powermac/udbg_scc.c    |  2 +-
 arch/powerpc/platforms/powernv/idle.c         |  6 +--
 arch/powerpc/platforms/powernv/opal-core.c    |  6 +--
 arch/powerpc/platforms/powernv/opal-fadump.c  |  2 +-
 arch/powerpc/platforms/powernv/opal-msglog.c  |  4 +-
 arch/powerpc/platforms/powernv/opal-power.c   |  2 +-
 .../powerpc/platforms/powernv/opal-powercap.c |  2 +-
 arch/powerpc/platforms/powernv/opal-rtc.c     |  2 +-
 .../platforms/powernv/opal-sensor-groups.c    |  4 +-
 arch/powerpc/platforms/powernv/opal.c         |  8 +--
 arch/powerpc/platforms/powernv/pci-ioda.c     |  4 +-
 arch/powerpc/platforms/powernv/powernv.h      |  4 +-
 arch/powerpc/platforms/powernv/rng.c          |  2 +-
 arch/powerpc/platforms/powernv/setup.c        |  6 +--
 arch/powerpc/platforms/ps3/gelic_udbg.c       |  2 +-
 arch/powerpc/platforms/ps3/mm.c               |  4 +-
 arch/powerpc/platforms/ps3/os-area.c          |  4 +-
 arch/powerpc/platforms/ps3/platform.h         | 14 ++---
 arch/powerpc/platforms/ps3/repository.c       | 20 +++----
 arch/powerpc/platforms/ps3/smp.c              |  2 +-
 arch/powerpc/platforms/ps3/spu.c              |  2 +-
 .../powerpc/platforms/pseries/event_sources.c |  2 +-
 arch/powerpc/platforms/pseries/iommu.c        |  2 +-
 arch/powerpc/platforms/pseries/lpar.c         |  6 +--
 arch/powerpc/platforms/pseries/pseries.h      |  2 +-
 arch/powerpc/platforms/pseries/rtas-fadump.c  |  6 +--
 arch/powerpc/platforms/pseries/setup.c        |  4 +-
 arch/powerpc/platforms/pseries/vas.c          |  2 +-
 arch/powerpc/platforms/pseries/vio.c          |  6 +--
 arch/powerpc/sysdev/cpm2.c                    |  6 +--
 arch/powerpc/sysdev/dart_iommu.c              |  2 +-
 arch/powerpc/sysdev/fsl_mpic_err.c            |  4 +-
 arch/powerpc/sysdev/fsl_pci.c                 |  2 +-
 arch/powerpc/sysdev/fsl_pci.h                 |  2 +-
 arch/powerpc/sysdev/i8259.c                   |  2 +-
 arch/powerpc/sysdev/ipic.c                    |  2 +-
 arch/powerpc/sysdev/mpic.c                    |  2 +-
 arch/powerpc/sysdev/mpic.h                    | 10 ++--
 arch/powerpc/sysdev/mpic_msi.c                |  6 +--
 arch/powerpc/sysdev/mpic_timer.c              |  6 +--
 arch/powerpc/sysdev/mpic_u3msi.c              |  2 +-
 arch/powerpc/sysdev/tsi108_pci.c              |  2 +-
 arch/powerpc/sysdev/udbg_memcons.c            |  2 +-
 arch/powerpc/sysdev/xics/icp-hv.c             |  2 +-
 arch/powerpc/sysdev/xics/icp-opal.c           |  2 +-
 arch/powerpc/sysdev/xics/xics-common.c        |  2 +-
 arch/powerpc/sysdev/xive/native.c             |  4 +-
 arch/powerpc/sysdev/xive/spapr.c              |  6 +--
 arch/powerpc/xmon/xmon.c                      |  2 +-
 include/linux/cuda.h                          |  2 +-
 include/linux/pmu.h                           |  2 +-
 150 files changed, 335 insertions(+), 334 deletions(-)
Signature · 1 line
2.25.1