From patchwork Tue Mar 31 10:04:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11467183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0953881 for ; Tue, 31 Mar 2020 10:05:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C178320781 for ; Tue, 31 Mar 2020 10:05:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cmh9cw24" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C178320781 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ED75C6B006E; Tue, 31 Mar 2020 06:05:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E881D6B0070; Tue, 31 Mar 2020 06:05:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9D306B0071; Tue, 31 Mar 2020 06:05:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id C024A6B006E for ; Tue, 31 Mar 2020 06:05:25 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7F2C81EF3 for ; Tue, 31 Mar 2020 10:05:25 +0000 (UTC) X-FDA: 76655225010.07.end59_1238826371b3b X-Spam-Summary: 40,2.5,0,3f5c437e40074344,d41d8cd98f00b204,laoar.shao@gmail.com,,RULES_HIT:41:355:379:541:973:988:989:1260:1345:1437:1535:1543:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3355:3743:3865:3866:3867:3868:3870:3871:3872:3874:4117:4605:5007:6261:6653:6755:7903:8784:9121:9413:10011:11026:11233:11473:11658:11914:12043:12219:12291:12297:12438:12517:12519:12679:12683:12895:13161:13229:14096:14394:14687:14721:14877:21080:21433:21444:21451:21627:21666:21740:30054:30070:30074,0,RBL:209.85.210.194:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:1:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: end59_1238826371b3b X-Filterd-Recvd-Size: 6214 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 31 Mar 2020 10:05:25 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id c21so9465886pfo.5 for ; Tue, 31 Mar 2020 03:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=MW/RUvnmQuaynAgrPchgXaGJmLy9K9MyZdsdP/atZxQ=; b=Cmh9cw24+M8BWilx0CjDUaHf3t3v0OLeGEIO8C7anSi3OCUwApzJwB0Hw7p6WnUU2H VzCDTbCiTCx7KjDthnON+VQ9NoMDSpUhT+dyRXmi24ctl3Fb0aCmyxTU/WO+Iub2adeN 6uWNuA1aM3OR5hjG2UcG4Lehhj4m3w3BbaM1/Y4WBCPWamS5d+6ZlHveR22Klk50zxcS 9+K3yze1rm4Nk9/eAQ65MJaRP7i21Szd89R3bx9w/2d9qbu+1rncnYSlV+ET69dVBcCS tDRaa0fYD76+XDtusbMepi42XR2QU8i5ydYHkqzBQacptIj9jIOcyJbHHZ/fDPQZ2U64 aaxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MW/RUvnmQuaynAgrPchgXaGJmLy9K9MyZdsdP/atZxQ=; b=rTyGlxv5/o1WyLVhSacigaUDDjfAP982JXcjT915oUvrq62scTC4uduXJQ1zESgqzT FxWk2aAN25VfQ+Acg6SzBxxVf/enY1sGJIMEuBRW5YL4Fnr2p6ZP0gtmsF1fsVyTw3Qy Nf/3IdeOh4QqD18JxY0pbw+nHomor1NW7o6WFVGsqBq6C8OubZZsfZd+EKBMq46jy9dW pPctbVFlHteu8RsoLbAIDHT9i0sJM2Ha7OrdhkD1/YsMOAF11QgGRZBGiFW7R93/Ea22 tWCcqN6n9J2vsgJugsctQKzL0jvFbEvnB6uyHmpkjMLfGMJI1ITpok4e2Ih2lRCRO0JF u5MQ== X-Gm-Message-State: ANhLgQ1V2QJIyn/AIH7Fe8uaFOsqIJa2Fm2X2whlqUe2bmdF3uLRY3i9 DwgwZMM5YrPeO6jB0MEryQI= X-Google-Smtp-Source: ADFU+vvFwk9gIaYwzFtN+osinFKTYw7KGYLSDcNh/AYWbMCZViWyLramfoAPmOtxgl1fyoVsw37kdA== X-Received: by 2002:a62:2a8c:: with SMTP id q134mr18037787pfq.35.1585649123998; Tue, 31 Mar 2020 03:05:23 -0700 (PDT) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id y207sm12354592pfb.189.2020.03.31.03.05.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2020 03:05:22 -0700 (PDT) From: Yafang Shao To: hannes@cmpxchg.org, peterz@infradead.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v2 0/2] psi: enhance psi with the help of ebpf Date: Tue, 31 Mar 2020 06:04:35 -0400 Message-Id: <1585649077-10896-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: PSI gives us a powerful way to anaylze memory pressure issue, but we can make it more powerful with the help of tracepoint, kprobe, ebpf and etc. Especially with ebpf we can flexiblely get more details of the memory pressure. In orderc to achieve this goal, a new parameter is added into psi_memstall_{enter, leave}, which indicates the specific type of a memstall. There're totally ten memstalls by now, MEMSTALL_KSWAPD MEMSTALL_RECLAIM_DIRECT MEMSTALL_RECLAIM_MEMCG MEMSTALL_RECLAIM_HIGH MEMSTALL_KCOMPACTD MEMSTALL_COMPACT MEMSTALL_WORKINGSET_REFAULT MEMSTALL_WORKINGSET_THRASH MEMSTALL_MEMDELAY MEMSTALL_SWAPIO With the help of kprobe or tracepoint to trace this newly added agument we can know which type of memstall it is and then do corresponding improvement. I can also help us to analyze the latency spike caused by memory pressure. But note that we can't use it to build memory pressure for a specific type of memstall, e.g. memcg pressure, compaction pressure and etc, because it doesn't implement various types of task->in_memstall, e.g. task->in_memcgstall, task->in_compactionstall and etc. Although there're already some tracepoints can help us to achieve this goal, e.g. vmscan:mm_vmscan_kswapd_{wake, sleep} vmscan:mm_vmscan_direct_reclaim_{begin, end} vmscan:mm_vmscan_memcg_reclaim_{begin, end} /* no tracepoint for memcg high reclaim*/ compcation:mm_compaction_kcompactd_{wake, sleep} compcation:mm_compaction_begin_{begin, end} /* no tracepoint for workingset refault */ /* no tracepoint for workingset thrashing */ /* no tracepoint for use memdelay */ /* no tracepoint for swapio */ but psi_memstall_{enter, leave} gives us a unified entrance for all types of memstall and we don't need to add many begin and end tracepoints that hasn't been implemented yet. Patch #2 gives us an example of how to use it with ebpf. With the help of ebpf we can trace a specific task, application, container and etc. It also can help us to analyze the spread of latencies and whether they were clustered at a point of time or spread out over long periods of time. To summarize, with the pressure data in /proc/pressure/memroy we know that the system is under memory pressure, and then with the newly added tracing facility in this patchset we can get the reason of this memory pressure, and then thinks about how to make the change. The workflow can be illustrated as bellow. REASON ACTION | compcation | improve compcation | | vmscan | improve vmscan | Memory pressure -| workingset | improve workingset | | etc | ... | Yafang Shao (2): psi: introduce various types of memstall psi, tracepoint: introduce tracepoints for psi_memstall_{enter, leave} block/blk-cgroup.c | 4 ++-- block/blk-core.c | 4 ++-- include/linux/psi.h | 15 +++++++++++---- include/linux/psi_types.h | 13 +++++++++++++ include/trace/events/sched.h | 41 +++++++++++++++++++++++++++++++++++++++++ kernel/sched/psi.c | 14 ++++++++++++-- mm/compaction.c | 4 ++-- mm/filemap.c | 4 ++-- mm/memcontrol.c | 4 ++-- mm/page_alloc.c | 8 ++++---- mm/page_io.c | 4 ++-- mm/vmscan.c | 8 ++++---- 12 files changed, 97 insertions(+), 26 deletions(-)