From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A632C5478C for ; Fri, 23 Feb 2024 17:38:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EBA66B0082; Fri, 23 Feb 2024 12:38:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 89E6C6B0083; Fri, 23 Feb 2024 12:38:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 718166B0085; Fri, 23 Feb 2024 12:38:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5CD186B0082 for ; Fri, 23 Feb 2024 12:38:38 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 27322C11B6 for ; Fri, 23 Feb 2024 17:38:38 +0000 (UTC) X-FDA: 81823778316.05.021C5FF Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by imf14.hostedemail.com (Postfix) with ESMTP id 7279F10000A for ; Fri, 23 Feb 2024 17:38:36 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="b76SI5k/"; spf=pass (imf14.hostedemail.com: domain of carlosgalo@google.com designates 209.85.219.52 as permitted sender) smtp.mailfrom=carlosgalo@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708709916; a=rsa-sha256; cv=none; b=tuyPmfTLFSZhgMOX/uKEKrP+94y5P1D6e/1l5M76mmK/IzJn8274Vt76krDRFN7xPc7zyQ C1nrvi4RDbNmrEZSAMqzieSZYXIm15Ua+IAbYybj9fx5Mt26BuvENODA9eaHx2RW3DMuGS Tf96kozZpVTR+KCxGppva6YKmuu7+ZI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="b76SI5k/"; spf=pass (imf14.hostedemail.com: domain of carlosgalo@google.com designates 209.85.219.52 as permitted sender) smtp.mailfrom=carlosgalo@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708709916; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EQha6Db7BGmzVAECCcFfEwysEpHphSP0pMsHuZkmas0=; b=ZXfLW/TuDVX+RBBP0kTknymYFHyPTWOhPtQXZd7FVRxkSHXl9OkEiBM9nIGPAVGLNN3PBg s2E9ZWSLH51QmuKI+vfs13/ZoVTB3mIfj4hZDVl4m+FQIEbuJAYblQ+eq0GNS8EdVEdXr3 10Z7o4ZOCTZ4wspgla5UadpdGxgMhEE= Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-68f54a65ae2so3345606d6.0 for ; Fri, 23 Feb 2024 09:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708709915; x=1709314715; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EQha6Db7BGmzVAECCcFfEwysEpHphSP0pMsHuZkmas0=; b=b76SI5k/JIbDBCJStrcQj5rj6Edn26aJk0JLpSCh3FXyvT7I1oWcRWT3vG4R2eZRGD XrBrD/X1Dmo1cx0/aTFohIwXScllVLWFHBYjVD1WKG1DmHM2+k2kIgu5n9GJ/RhnqrKZ PnYcWdMMEBxwaCyInup1xaafbnwHkgyGt4tZRxNwbr9kbp7VHCo59U8kaU3OOgG4Zf9p ZBlU1+z8iQONXAYxxerFl8W+FQG2gh82WEg3LB5LmtsUYjI8947fO8eCrKU3JSBfigmA yhdY7ZQLaH9G/9fwEZ17WETHs1QDlP7b53QkdBOVyo/YMGPFvKRsKxaPQM9MVeHAOm8H RW7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708709915; x=1709314715; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EQha6Db7BGmzVAECCcFfEwysEpHphSP0pMsHuZkmas0=; b=AOnZtECKZV2z9nxBGlymbZp23468cjMv8MEh++9iuODuwxXq9bsWemPHnR+98Z9r2s x7SKUhLkIDgp2JmV00Z9KBOkT/e+zV/psZsns8oDnMDu/XCx3PDHFQXovlOI64lwHIfO hXhNIQL/QRxXk/iaB61NxySh5K6YHIOALELffgDiEgxF6U486I5ay2U2iMIhgDSA9N3q uM7AJHm2mS+XqPBmSwHJ8vN3+l2vNk3T9NyQor40l/C97s53RH39VxfR8+hGH3IpCsBH OG+LcN3HeO3FY4/p2DtnnZd8njKqvNsqWf5Xbh460kmF4L/9DhPZlQbhzYETZqzVoGaS I+zQ== X-Forwarded-Encrypted: i=1; AJvYcCWHf8AJjq/VGqMIUt6PoBHEoLYf+iJzFQvW9SvxrGba+sSzFOI1mOuciNnoXUsc4QMFGtISmBg8ivL70oilVKtamqE= X-Gm-Message-State: AOJu0YxjMtEC9uaXmMa2JdYit/I1lQRkbJnconi5aVqk7DgARPxsMLF7 2ofz7wajUmFU/xVWLYkAa/FOnHNzR1JaT7TF0M52hOLeLZC2swU5he8HYM3DQmJFk6avpyRN6jH Zv+zdXGsYgSMwzq3w3wOR1HdM8dLorI3Bt6yP X-Google-Smtp-Source: AGHT+IGZ8nB/bBWl1cHIQ2s49iIYkm/IyW2oZ+4Wnr8YByscHIMWXGlJ1RtmEoQ14Agew8SXUnnP/DWdmS2TDOqWrNM= X-Received: by 2002:a05:6214:2b8a:b0:68c:425b:ea9 with SMTP id kr10-20020a0562142b8a00b0068c425b0ea9mr668685qvb.42.1708709915421; Fri, 23 Feb 2024 09:38:35 -0800 (PST) MIME-Version: 1.0 References: <20240111210539.636607-1-carlosgalo@google.com> In-Reply-To: From: Carlos Galo Date: Fri, 23 Feb 2024 09:38:22 -0800 Message-ID: Subject: Re: [PATCH v2] mm: Update mark_victim tracepoints fields To: Michal Hocko Cc: rostedt@goodmis.org, akpm@linux-foundation.org, surenb@google.com, android-mm@google.com, kernel-team@android.com, Masami Hiramatsu , Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7279F10000A X-Stat-Signature: jrncr69u3ni94yswt9ys3hgxwcrdpxm3 X-Rspam-User: X-HE-Tag: 1708709916-50683 X-HE-Meta: U2FsdGVkX186xf8d44hwJMBCffnCmi54d9wjZp3wxr9GF4CvarDHgM6E7ZNV3Te7L0kJqnIwfWIqKWUMvL/JNaSHO8nSAYNmTklNhds3BfaXpxAUw2A6aJNQmRxP72zE16R8VCHjKXLniTmBkAw4386sO0+kJsM54wP8Rf8e+75pmAa2CFulqsYhIWKzCnVFOax5cuPYeQ1LOxw0k+/YdkF0HmCpt1F7PMUzQhc6KELmTsHzZcb9Lf25nIaJ36NyCGQdrI/Skj2WNbtOx7mo5UBRAq63Yr9Xgqby82M8n68T8KF0zxO1Mjsngfd0BGqgJErsAhDXtcITX+PxO6v/m1H9xe8X3KWmgT/mJw8ge/X7cJLSsfcYTwqkk2IEPgBoCztCvn9B53WP4K70+jy6s2Nst1CSPF5kp6ilUaRBoRz6iMDNSaQAzG3ICkfisjv2ONAhu2McONQMXEjVxo4uqaSMxkK4yXAmGXOIaG+/OqeXE2LqKOqqZayFgoIHaLX4Ap9FUcI6eQ4XnpvxdoGfYjwSdvzOwVtCHmY1j9AvJjkObh68Z/fAf2kbdmTkhcMyecSw6Ee+xZKcAhQEI54kEtCyHnA8pPY4n+VHoxmu/eIDQ0oGhCS+JOqvZM4Q+EyRdc+EOwYbylwHz+cb+vf4rhLn6CZaWiA8TTWT2R1wU5hyQczQBZbib/G106mRfciyUePCxMxNr41/QXGiNH52wMFEWiIqeZtY2f9gAHzuarFezhyPdWxTvJXoRslCa5EO5oIbJj2IMieOHp83O5B10sGHfnpw6qEkgxsl4hZ7ot0OGVR+1SeEiNMKi9pGqd8z2y//z/JOaHb13P1Wh5GLdQIy1BZ5A4aLYVuHuBHAW564OqZDOwesCHXInTw1FeFk8Jlpc8qqgWplM0TvbmfLz65u1YKdjJPXqUiP7y/KfcNFNxqH4oYyfvxKjTnd2DRTyNDJykt/PLeSARpp/5J 4+O6vjIW vyBDidPGGX0vMo11Py5kAgEV1Ovt/eOCoYDpZzGwZRGwhgmc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.227690, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Feb 22, 2024 at 9:59=E2=80=AFAM Carlos Galo = wrote: > > On Thu, Feb 22, 2024 at 6:16=E2=80=AFAM Michal Hocko wr= ote: > > > > On Wed 21-02-24 13:30:51, Carlos Galo wrote: > > > On Tue, Feb 20, 2024 at 11:55=E2=80=AFPM Michal Hocko wrote: > > > > > > > > Hi, > > > > sorry I have missed this before. > > > > > > > > On Thu 11-01-24 21:05:30, Carlos Galo wrote: > > > > > The current implementation of the mark_victim tracepoint provides= only > > > > > the process ID (pid) of the victim process. This limitation poses > > > > > challenges for userspace tools that need additional information > > > > > about the OOM victim. The association between pid and the additio= nal > > > > > data may be lost after the kill, making it difficult for userspac= e to > > > > > correlate the OOM event with the specific process. > > > > > > > > You are correct that post OOM all per-process information is lost. = On > > > > the other hand we do dump all this information to the kernel log. C= ould > > > > you explain why that is not suitable for your purpose? > > > > > > Userspace tools often need real-time visibility into OOM situations > > > for userspace intervention. Our use case involves utilizing BPF > > > programs, along with BPF ring buffers, to provide OOM notification to > > > userspace. Parsing kernel logs would be significant overhead as > > > opposed to the event based BPF approach. > > > > Please put that into the changelog. > > Will do. > > > > > > In order to mitigate this limitation, add the following fields: > > > > > > > > > > - UID > > > > > In Android each installed application has a unique UID. Includ= ing > > > > > the `uid` assists in correlating OOM events with specific apps= . > > > > > > > > > > - Process Name (comm) > > > > > Enables identification of the affected process. > > > > > > > > > > - OOM Score > > > > > Allows userspace to get additional insights of the relative ki= ll > > > > > priority of the OOM victim. > > > > > > > > What is the oom score useful for? > > > > > > > The OOM score provides us a measure of the victim's importance. On th= e > > > android side, it allows us to identify if top or foreground apps are > > > killed, which have user perceptible impact. > > > > But the value on its own (wihtout knowing scores of other tasks) doesn'= t > > really tell you anything, does it? > > Android uses the OOM adj_score ranges to categorize app state > (foreground, background, ...). I'll resend a v3 with the commit text > updated to include details about this. > > > > > Is there any reason to provide a different information from the one > > > > reported to the kernel log? > > > > __oom_kill_process: > > > > pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, = file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n"= , > > > > message, task_pid_nr(victim), victim->comm, K(mm->t= otal_vm), > > > > K(get_mm_counter(mm, MM_ANONPAGES)), > > > > K(get_mm_counter(mm, MM_FILEPAGES)), > > > > K(get_mm_counter(mm, MM_SHMEMPAGES)), > > > > from_kuid(&init_user_ns, task_uid(victim)), > > > > mm_pgtables_bytes(mm) >> 10, victim->signal->oom_sc= ore_adj); > > > > > > > > > > We added these fields we need (UID, process name, and OOM score), but > > > we're open to adding the others if you prefer that for consistency > > > with the kernel log. > > > > yes, I think the consistency would be better here. For one it reports > > numbers which can tell quite a lot about the killed victim. It is a > > superset of what you already asking for. With a notable exception of th= e > > oom_score which is really dubious without a wider context. > > Sounds good, I'll resend a v3 that includes these fields as well. > > Thanks, > Carlos > I posted V3 here: https://lore.kernel.org/all/20240223173258.174828-1-carlosgalo@google.com/ Thanks, Carlos > > -- > > Michal Hocko > > SUSE Labs