Nп/п : 53 из 100
 От   : Kalevi Kolttonen                    2:5075/128        29 авг 23 16:01:38
 К    : Kalevi Kolttonen                                      29 авг 23 19:03:04
 Тема : Re: getrlimit RLMIT_NPROC
----------------------------------------------------------------------------------
                                                                                 
@MSGID: 1@dont-email.me> 6e944dfb
@REPLY: 1@dont-email.me> 50edfcea
@REPLYADDR Kalevi Kolttonen <kalevi@kolttonen.fi>
@REPLYTO 2:5075/128 Kalevi Kolttonen
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: 1@dont-email.me>
@RFC-References: 1@news.xmission.com>
1@dont-email.me> 1@dont-email.me>
@TZUTC: -0000
@PID: tin/2.6.2-20221225 ("Pittyvaich")
(Linux/6.4.12-200.fc38.x86_64 (x86_64))
@TID: FIDOGATE-5.12-ge4e8b94
Kalevi Kolttonen <kalevi@kolttonen.fi> wrote:
> 2) Maybe the Linux kernel sets the default value based
>    on how much RAM is available.

Inspecting kernel/fork.c, we see:

static void set_max_threads(unsigned int max_threads_suggested)
{
        u64 threads;
        unsigned long nr_pages = totalram_pages();

        /*
         * The number of threads shall be limited such that the thread
         * structures may only consume a small part of the available memory.
         */
        if (fls64(nr_pages) + fls64(PAGE_SIZE) > 64)
                threads = MAX_THREADS;
        else
                threads = div64_u64((u64) nr_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);
}

It seems to me that that eventually sets "max_threads" based on 
available RAM, with the limitation that "max_threads_suggested"
must not be exceeded.

Further, fork_init() we have:

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

It looks like RLIMIT_NRPOC limits are based on the value of max_threads/2.

In conclusion, I believe the values you and I saw are based on how much
RAM our Linux systems have.

br,
KK
--- tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.4.12-200.fc38.x86_64 (x86_64))
 * 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    
                                                                                
В этой области больше нет сообщений.

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