nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

sched/kconfig: add PIDHASH_INITIAL_LENGTH

Open yf13 opened this issue 1 year ago • 3 comments

Summary

sched/Kconfig: add PIDHASH_INITIAL_LENGTH option

This adds the flexibility to configure pid hash table length. It allows to provision the table right at once for cases where number of threads are known at design time.

Impact

None

Testing

  • Local test with rv-virt/nsh and rv-virt/nsh64
  • CI checking

yf13 avatar May 30 '24 07:05 yf13

@xiaoxiang781216 and @acassis

Looks like CI system breaks?

Configuration/Tool: smartl-c906/sotest
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
riscv-none-elf-ld: dynload.o: ABI is incompatible with that of the selected emulation:
  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
riscv-none-elf-ld: failed to merge target specific data of file dynload.o
riscv-none-elf-ld: warning: cannot find entry symbol _start; defaulting to 00010074
make[4]: *** [Makefile:45: dynload] Error 1

With stock toolchain gcc-riscv64-unknown-elf on Ubuntu 22.04, this config can be built with makefile locally, maybe I am using a not so recent version.

yf13 avatar May 30 '24 23:05 yf13

please rebase, that PR was reverted

acassis avatar May 30 '24 23:05 acassis

@yf13 How about restore the restrictions of CONFIG_MAX_TASKS? #4117

There are two benefits:

  1. avoid accessing memory allocators
  2. same benefits as PIDHASH_INITIAL_LENGTH, and CONFIG_MAX_TASKS is more concise and easy to understand

anchao avatar May 31 '24 04:05 anchao

@yf13 How about restore the restrictions of CONFIG_MAX_TASKS? #4117

There are two benefits:

  1. avoid accessing memory allocators
  2. same benefits as PIDHASH_INITIAL_LENGTH, and CONFIG_MAX_TASKS is more concise and easy to understand

but not all products can easily predicate the accuracy number of threads required by runtime. PIDHASH_INITIAL_LENGTH plus the static array could satisfy both usages.

xiaoxiang781216 avatar May 31 '24 07:05 xiaoxiang781216

but not all products can easily predicate the accuracy number of threads required by runtime. PIDHASH_INITIAL_LENGTH plus the static array could satisfy both usages.

Yes, what I mean is not to completely remove the dynamic alloc of g_pidhash, just add the maximum number of tasks in deterministic design time.

#if CONFIG_MAX_TASKS == 0
FAR struct tcb_s **g_pidhash;
#else
FAR struct tcb_s g_pidhash[CONFIG_MAX_TASKS];
#endif

anchao avatar May 31 '24 09:05 anchao

@anchao as current approach already supports both static and dyanmic pid ranges, maybe we can stick with it and just see if there are better names?

Other names I can tell are: INITIAL_PID_LIMIT, INITIAL_PID_RANGE etc. For cases where max pid is known at design time, simply set it in INITIAL_PID_LIMIT.

yf13 avatar May 31 '24 23:05 yf13

@anchao as current approach already supports both static and dyanmic pid ranges, maybe we can stick with it and just see if there are better names?

Other names I can tell are: INITIAL_PID_LIMIT, INITIAL_PID_RANGE etc. For cases where max pid is known at design time, simply set it in INITIAL_PID_LIMIT.

@yf13 Let's keep this name for now, I mainly want to eliminate allocator access, but which should not be implemented in this PR. Please address @xiaoxiang781216 comments.

anchao avatar Jun 01 '24 02:06 anchao

@anchao, eliminating allocator use during boot time is a large topic that can be discussed separately. my purpose is just to achieve leakless ostest.

Also thanks for reminding as I didn't see the in-place comments from gh command line, here I use gh most time as browser access to github is too unstable. In my latest update, I've renamed the config as INITIAL_PID_LIMIT and also addressed @xiaoxiang781216's comments.

yf13 avatar Jun 01 '24 04:06 yf13

@anchao, how do you find out patch 4117 from commit 00cf12b? I don't see a method in gh pr command.

yf13 avatar Jun 01 '24 07:06 yf13

Looks like CI is broken? Got below from Linux (arm-01):

Configuration/Tool: ntosd-dm320/udp,CONFIG_ARM_TOOLCHAIN_GNU_EABI
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Building NuttX...
make[1]: *** No rule to make target '/github/workspace/sources/nuttx/.config'.
make[1]: Failed to remake makefile '/github/workspace/sources/nuttx/.config'.
make: *** [tools/Unix.mk:268: tools/cnvwindeps] Error 2

yf13 avatar Jun 01 '24 09:06 yf13

@anchao, how do you find out patch 4117 from commit 00cf12b? I don't see a method in gh pr command.

@yf13 You could type .patch at the end of the URL and refresh the URL or press enter to go the URL if you just want the patch file:

https://github.com/apache/nuttx/pull/4117.patch

anchao avatar Jun 03 '24 00:06 anchao

@anchao, thanks for teach this URL rule. If I get commit id 00cf12b from my local repo (e.g. via git blame), how can I find the PR number 4117 which includes that commit from Github?

yf13 avatar Jun 03 '24 01:06 yf13

@yf13 I'm not familiar with how to search the PR in the CLI, for website maybe you can search for commit id in nuttx repo to get out the corresponding PR:

image

anchao avatar Jun 03 '24 04:06 anchao

@anchao, many thanks! I tried the web search, now both 4117 and this PR are returned. It is so nice of you!

yf13 avatar Jun 03 '24 08:06 yf13

@yf13 another you to test a PR without downloading and applying it manually:

git fetch upstream pull/1234/head
git checkout FETCH_HEAD

Assuming 1234 is the number your PR

More info: https://acassis.wordpress.com/2022/02/24/how-to-test-a-pr-before-it-get-integrated-on-nuttx/

acassis avatar Jun 03 '24 18:06 acassis

@acassis thanks for the git tips! guess it is the thing behind gh pr checkout 1234. Unfortunately I can't access wordpress in China, will check them later when there are chances.

yf13 avatar Jun 04 '24 00:06 yf13