2013-11-14 05:59:14 +08:00
|
|
|
############################################################################
|
|
|
|
# fs/procfs/Make.defs
|
|
|
|
#
|
2021-02-03 21:47:23 +08:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership. The
|
|
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance with the
|
|
|
|
# License. You may obtain a copy of the License at
|
2013-11-14 05:59:14 +08:00
|
|
|
#
|
2021-02-03 21:47:23 +08:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2013-11-14 05:59:14 +08:00
|
|
|
#
|
2021-02-03 21:47:23 +08:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2013-11-14 05:59:14 +08:00
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_FS_PROCFS),y)
|
|
|
|
# Files required for procfs file system support
|
|
|
|
|
2023-03-15 20:48:40 +08:00
|
|
|
CSRCS += fs_procfs.c fs_procfscpuinfo.c fs_procfscpuload.c
|
2023-05-07 15:13:31 +08:00
|
|
|
CSRCS += fs_procfscritmon.c fs_procfsfdt.c fs_procfsiobinfo.c
|
|
|
|
CSRCS += fs_procfsmeminfo.c fs_procfsproc.c fs_procfstcbinfo.c
|
|
|
|
CSRCS += fs_procfsuptime.c fs_procfsutil.c fs_procfsversion.c
|
2018-11-25 03:33:37 +08:00
|
|
|
|
procfs: add memory pressure notification support
This is a memory monitoring interface implemented with reference to Linux's PSI (Pressure Stall Information),
which can send notifications when the system's remaining memory is below the threshold.
The following example code sets two different thresholds.
When the system memory is below 10MB, a notification is triggered.
When the system memory is below 20 MB, a notification (POLLPRI event) is triggered every 1s.
```
int main(int argc, FAR char *argv[])
{
struct pollfd fds[2];
int ret;
if (argc == 2)
{
char *ptr = malloc(1024*1024*atoi(argv[1]));
printf("Allocating %d MB\n", atoi(argv[1]));
ptr[0] = 0;
return 0;
}
fds[0].fd = open("/proc/pressure/memory", O_RDWR);
fds[1].fd = open("/proc/pressure/memory", O_RDWR);
fds[0].events = POLLPRI;
fds[1].events = POLLPRI;
dprintf(fds[0].fd, "%llu -1", 1024LLU*1024 * 10);
dprintf(fds[1].fd, "%llu 1000000", 1024LLU*1024 * 20);
while (1)
{
ret = poll(fds, 2, -1);
if (ret > 0)
{
printf("Memory pressure: POLLPRI, %d\n", ret);
}
}
return 0;
}
```
https://docs.kernel.org/accounting/psi.html
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-11-29 21:59:49 +08:00
|
|
|
ifeq ($(CONFIG_FS_PROCFS_INCLUDE_PRESSURE),y)
|
|
|
|
CSRCS += fs_procfspressure.c
|
|
|
|
endif
|
|
|
|
|
2013-11-14 05:59:14 +08:00
|
|
|
# Include procfs build support
|
|
|
|
|
|
|
|
DEPPATH += --dep-path procfs
|
|
|
|
VPATH += :procfs
|
|
|
|
|
|
|
|
endif
|