From patchwork Thu Mar 26 11:12:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11459853 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 136FF6CA for ; Thu, 26 Mar 2020 11:12:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D196620748 for ; Thu, 26 Mar 2020 11:12:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eJpCgo34" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D196620748 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 0CC1F6B0070; Thu, 26 Mar 2020 07:12:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 07D586B0071; Thu, 26 Mar 2020 07:12:44 -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 EAE966B0072; Thu, 26 Mar 2020 07:12:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id D06DA6B0070 for ; Thu, 26 Mar 2020 07:12:43 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B773F180AD80F for ; Thu, 26 Mar 2020 11:12:43 +0000 (UTC) X-FDA: 76637250606.24.sand63_17c925866e757 X-Spam-Summary: 40,2.5,0,7772e5e23eaa3517,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:3354:3743:3865:3866:3867:3868:3870:3871:3872:3874:4605:5007:6261:6653:6755:7903:8784:9121:9413:10011:11026:11233:11473:11658:11914:12043:12048:12219:12291:12297:12438:12517:12519:12679:12683:12895:14096:14394:14687:14721:14877:21080:21433:21444:21451:21627:21666:21740:30054:30074,0,RBL:209.85.210.195:@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: sand63_17c925866e757 X-Filterd-Recvd-Size: 5820 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Mar 2020 11:12:43 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id 23so2611973pfj.1 for ; Thu, 26 Mar 2020 04:12:43 -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=UzzDt0/zC8t7ovhe7yIj9+UNLH3ZfB9o+FewH6cOgh4=; b=eJpCgo34rTMlyH3BQTttLC8UZfwApCAG/DM+Q6SPEsyflv8/b0pm1u0BWgpAsFEsDN LinFDIZOcxNI7oIt+5KyIMBr/pnzuH+wKN1Sua3xMiPXT40HlPYSBa4A3HYZBBR/okXG B+Gd2XqPkQLdJNnPwnIvPGwsZ3okp74+Gi6RaTd6Tq7fnwm4HNBQILCRWs9O/9/9VxWz WjnqyyApKROpRAwLQsANc/upj2KMXuL81L7kEIlTmCok8V9sPba9ToDQs325MFeGIbCz jrbZy5gWvA0nirDhtNON1JeWDZvj+EgDQ6aiLZXFHPPp78GN6mVyeqgp693wacyk2ACO N1ag== 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=UzzDt0/zC8t7ovhe7yIj9+UNLH3ZfB9o+FewH6cOgh4=; b=MdgQEjjOOi7HtR8X91ByJECCKlkqKcvCiRV21PZjE+6x2yFtzvFgHhEiwyqh5SZWrl CH0chFr7yX092CrM2D1VU5PqMiW9kJVJosAOi6DqtpCPzvBtWaric/ViEf852K3mJDkS wGC+V/oLnz9Pg0DB9tLU/MUpxIJxf9RZpzSLaRITvA8dj4DL8mhVgrD7n0rze8riDN88 kR2ieLL9UQM3rGLR/oaq2unyT0KeawIJdDNl+Fi0yv7hRsR1z2ig2rUszD1oYl/YbXWs ngvaufoxJdEHZX8ifSZBPCqxdTDh1GBhms8z9qMRwuFFzRdhRf47VkBficVmAxL2PzlS /z3Q== X-Gm-Message-State: ANhLgQ2VruWnecnKWlLfX8Pjlvkm4vj6jBkoUTzvmKy9dAZsr+F/GvJJ riTZEII5CX3StJUpUK4zjRo= X-Google-Smtp-Source: ADFU+vvamjy5zGNHJhHUhozynw5nSgVNpikKb1pWFXwb+S/0IjyUw+YsyDdNm/I7Qw9TJEhOD73epQ== X-Received: by 2002:a62:6807:: with SMTP id d7mr8529801pfc.230.1585221161955; Thu, 26 Mar 2020 04:12:41 -0700 (PDT) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id m9sm1427723pff.93.2020.03.26.04.12.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2020 04:12:41 -0700 (PDT) From: Yafang Shao To: hannes@cmpxchg.org, peterz@infradead.org, akpm@linux-foundation.org, mhocko@kernel.org, axboe@kernel.dk, mgorman@suse.de, rostedt@goodmis.org, mingo@redhat.com Cc: linux-mm@kvack.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH 0/2] psi: enhance psi with the help of ebpf Date: Thu, 26 Mar 2020 07:12:05 -0400 Message-Id: <1585221127-11458-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_THRASHING 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. 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(-)