pid start time and new display field in proc pid stat

Navin P navinp0304 at gmail.com
Thu Mar 25 23:01:20 EDT 2021


On Thu, Mar 25, 2021 at 8:51 PM <jim.cromie at gmail.com> wrote:
>
>
>
> On Thu, Mar 25, 2021 at 6:53 AM Navin P <navinp0304 at gmail.com> wrote:
>>
>> Hi,
>>
>>  As of 5.11 kernel (pid,pid_start_time) is not unique /monotonic even
>> though the underlying counters are .
>>  I chose start_boottime because i wanted the counter to increase
>> during suspend as well.
>>
>> 1. Is there any case where task->start_boottime or
>> ktime_get_boottime_ns doesn't become monotonic i.e increasing ?
>>
>> 2.  If start_boottime is not monotonic which counter to use ?
>>
>> 3.  If i create a new field in task_struct , then i can use a
>> atomic_add_return(1,&v) to fill in the task->new_field. Will this also
>> work ?
>>
>
> Its my understanding that task-struct is a highly "contended" resource.
>
> its a basic element, its size matters
> everybody wants a bit/byte for something special,
> conflicts ensue (or could).
> nobody gets them without a real good reason.
>
> I dont know what youre trying to achieve, but i suspect that
> youll need to find a more subtle way of doing it.


Yes creating a new field is not appropriate. I was checking on the
other options in case a similar problem occurs, like other ways of
solving this problem.

My patch doesn't create a new field, it uses the existing field and
prints it in /proc/[pid]/stat. Stat files are created
on first lookup. These are used by ps or top.

+ seq_put_decimal_ull(m, " ", task->start_boottime);



More information about the Kernelnewbies mailing list