Nп/п : 62 из 100
 От   : Kaz Kylheku                         2:5075/128        29 авг 23 19:01:25
 К    : Kalevi Kolttonen                                      29 авг 23 22:03:01
 Тема : Re: getrlimit RLMIT_NPROC
----------------------------------------------------------------------------------
                                                                                 
@MSGID: <20230829113945.477@kylheku.com> 35c3a69f
@REPLY: 1@dont-email.me> 50edfcea
@REPLYADDR Kaz Kylheku <864-117-4973@kylheku.com>
@REPLYTO 2:5075/128 Kaz Kylheku
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: <20230829113945.477@kylheku.com>
@RFC-References: 1@news.xmission.com>
1@dont-email.me> 1@dont-email.me>
@TZUTC: -0000
@PID: slrn/pre1.0.4-9 (Linux)
@TID: FIDOGATE-5.12-ge4e8b94
On 2023-08-29, Kalevi Kolttonen <kalevi@kolttonen.fi> wrote:
> Kalevi Kolttonen <kalevi@kolttonen.fi> wrote:
>> Using grep, I was unable to find where 60988 is set
>> on my Fedora 38. So my best guess is that this value 
>> has been set when compiling the kernel.
>
> I downloaded the current Fedora 38 kernel sources. The
> value 60988 is nowhere to be found. Some possible reasons:
>
> 1) Maybe 60988 value was given as a command line parameter 
>    when running "make". I suppose this is quite unlikely and
>    I did not investigate the Makefiles to see whether that
>    is even supported.

Pretty much nobody is going to do 

  #define DEFAULT_THING 60988 // or other weird number.

Plus, we are seeing different numbers on different systems

> 2) Maybe the Linux kernel sets the default value based
>    on how much RAM is available.

Precisely. It looks calculated. You have to find the area of the kernel
where the rlimit sysdcalls are implemented. Find out which fields in the
task struct they are coming from, then search where those are set up.

I`m looking at 4.9.211 (a kernel I work with in in my embedded work).

In kernel/fork.c, there is a fork_init() function with these lines:

  init_task.signal->rlim[RLIMIT_NPROC].rlim_cur = max_threads/2; 
  init_task.signal->rlim[RLIMIT_NPROC].rlim_max = max_threads/2; 

max_threads is a tunable global variable initialized earlier
in that same function by call to set_max_threads(MAX_THREADS).
That function only uses the parameter as an upper bound clamp.

It perpetrates a complex calculation from totalram_pages and
thread context size:

 static void set_max_threads(unsigned int max_threads_suggested) 
 { 
  u64 threads; 
  
  /* 
  * The number of threads shall be limited such that the thread 
  * structures may only consume a small part of the available
memory. 
  */ 
  if (fls64(totalram_pages) + fls64(PAGE_SIZE) > 64) 
  threads = MAX_THREADS; 
  else 
  threads = div64_u64((u64) totalram_pages * (u64) PAGE_SIZE, 
  (u64) THREAD_SIZE * 8UL); 
  
  if (threads > max_threads_suggested) 
  threads = max_threads_suggested; 
  
  max_threads = clamp_t(u64, threads, MIN_THREADS, MAX_THREADS); 
 } 

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
--- slrn/pre1.0.4-9 (Linux)
 * Origin: A noiseless patient Spider (2:5075/128)
SEEN-BY: 5001/100 5005/49 5010/352 5015/255 5019/40
5020/715 848 1042 4441
SEEN-BY: 5020/12000 5030/49 1081 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх