Documentation/translations/zh_CN/accounting/psi.rst

Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/accounting/psi.rst

File Facts

System
Linux kernel
Corpus path
Documentation/translations/zh_CN/accounting/psi.rst
Extension
.rst
Size
6182 bytes
Lines
156
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

int main() {
        const char trig[] = "some 150000 1000000";
        struct pollfd fds;
        int n;

        fds.fd = open("/proc/pressure/memory", O_RDWR | O_NONBLOCK);
        if (fds.fd < 0) {
                printf("/proc/pressure/memory open error: %s\n",
                        strerror(errno));
                return 1;
        }
        fds.events = POLLPRI;

        if (write(fds.fd, trig, strlen(trig) + 1) < 0) {
                printf("/proc/pressure/memory write error: %s\n",
                        strerror(errno));
                return 1;
        }

        printf("waiting for events...\n");
        while (1) {
                n = poll(&fds, 1, -1);
                if (n < 0) {
                        printf("poll error: %s\n", strerror(errno));
                        return 1;
                }
                if (fds.revents & POLLERR) {
                        printf("got POLLERR, event source is gone\n");
                        return 0;
                }
                if (fds.revents & POLLPRI) {
                        printf("event triggered!\n");
                } else {
                        printf("unknown event received: 0x%x\n", fds.revents);
                        return 1;
                }
        }

        return 0;
  }

Cgroup2接口
===========

对于CONFIG_CGROUP=y及挂载了cgroup2文件系统的系统,能够获取cgroups内任务的psi。
此场景下cgroupfs挂载点的子目录包含cpu.pressure、memory.pressure、io.pressure文件,
内容格式与/proc/pressure/下的文件相同。

可设置基于cgroup的psi监控器,方法与系统级psi监控器相同。

Annotation

Implementation Notes