Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2695510lqt; Mon, 22 Apr 2024 20:45:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIM+WhJcmHI5d70YLwTrWtX7R1P0oBhbH1tBGaZ9nLdQRupvGducw/vyIgbxKf4w6xO/hfWU6mGPOHrtwMTk0MmmEyqy9C3f3C89ieYw== X-Google-Smtp-Source: AGHT+IEd29nmvu0sVSpPZ0ZQb670mQTOo1W9hS6PAb2NdiVw+os9BzNx+FRTqTZzq1WEG8lSmCdZ X-Received: by 2002:a05:6a20:12ce:b0:1a9:c4ca:dc74 with SMTP id v14-20020a056a2012ce00b001a9c4cadc74mr15314130pzg.5.1713843907655; Mon, 22 Apr 2024 20:45:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713843907; cv=pass; d=google.com; s=arc-20160816; b=RUyWJzOo+vWf//zbh7UekN1cCIQPT7cX9VECzmFeW+/MXn3/YKC0/7tcqMCAA/Ap1C qlJzIm5L6hP60OqqoS2VLKI9v+5iJ8vrsyPQ63pm8LHQ5vJUqy/yTjrKs8uZjuJxtXjI L3jBYy+EfaLAbS7ipzx96hwTgW86tWDiQHlPIXQG3EnOx31Aw7gZFhoXv1uj4TR5qgYv 2xsbRsJkSuOIqyy3JMwflUGlLlR/ac0RnX6Q76Dx/yX5MhcEAo4sSxTIYtamhwahgJyr xX17QiFk+2mafYEI0S3jUauJg+nY55cZ2O4NGFlLXn0qeNTLSdlhr5t6pk34TX+2DoRs m9ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Zk8sHHlFZ5yMas0e7wt0QxJKNRueI84ut/8EKgUk1gU=; fh=8j3cshPcKC8dh7LNhAimwJd791iUI4B10zfUQz02DzE=; b=dI9pWEM8NRaBAeOlUWILZlPMQ4LXfZHpXiL+bXIfdU3CF2fgzyQb+b2WWvtFahYSYx X6A4l2s/vBPqEE1qm63UyqzmZLY0VWNVZZmvk08xosY2yoByQ0ft61tm1GJx9y1LsfnA xUKHOOX9IiKsEtbpCvRM0ya6hdb2Py282xohjVf2nHtDong2zO+vU2V7Z2qO5FuYAtr9 dapdeNYQA1aEFpTnKMgH7XI5O/w/F3gzjSVAqPz+N5xMtANcCGNPFY2aNAV7SmdRKZgf a2iSAogg94cowJE7hLTAQohApUEXTjPY3xrkppUtxQXMLkGwC9N0TIsDzrDe+f4N7/sJ h71w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=E2iiYPuH; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-154464-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b9-20020a170903228900b001e264881bc3si8997188plh.130.2024.04.22.20.45.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 20:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154464-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=E2iiYPuH; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-154464-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3D44AB21852 for ; Tue, 23 Apr 2024 03:41:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCF281C2BD; Tue, 23 Apr 2024 03:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="E2iiYPuH" Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EFEC1F934 for ; Tue, 23 Apr 2024 03:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713843686; cv=none; b=OsVIvCatpOjA7PcNwAYykjQS0CJtva3n8GMf/OAZQBZJX2Rx1fiaP+rnPStwytq6O3Xs5j53u/BelzzWfH5W+6CGBeoQnd1SITGYcn+90u0LtcrMAHE45+vgd39mWHJkP8buvJFGZxSBBDYJO0vN+Wssxlf9MuCe5MhxYdqA6Po= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713843686; c=relaxed/simple; bh=og/1Bh1HmmM5su2/my/Vew9YvJYFlLIPs0D6nqUUBV4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Eqo+9DfKT/z2kEfyQIbqcPICAwaCx+r+k4YIiLu0vVvtdPzLTNau0i0rzM5k8RNPjtJveF97JEgjCfOekRCYdVGHvYRdc12N0IyspLoLIasqkvNrFevJ2UP6JISeQv03RTcFQUSTCgAuVbDDmcLQ8d4NfmTaMEXRWy2ZVdso5kE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=E2iiYPuH; arc=none smtp.client-ip=209.85.166.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-7da37436e36so204082139f.0 for ; Mon, 22 Apr 2024 20:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1713843683; x=1714448483; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zk8sHHlFZ5yMas0e7wt0QxJKNRueI84ut/8EKgUk1gU=; b=E2iiYPuHOseBUVaZBchysHsQOOYWR5njICBeqjKVeriE3PjZql5ialdTz8bcnINDo1 tjnwHTDcqZg9dMAq8g7S7UBVno4o2cc+I7XjsB77+x8lMlNpR0fR/yByjEozrT48GR4f CZf9zVV1aeNa+86l5sGAecCg6hc7zf8X5LqVTVDinUjLucteG8pyvWk3ai7QeJguop3c 0W3XX90KIM3abb5/eiW7B9hjHnu3tcyAXGJXDmR//cWEWthqSmHwPHCL3XQ2actqPe19 M3gs37Opg1rgoDVm6quTzcfnraZiCJikRQ/vi3EzKJiF1BEo1PQS7lWXSbS6tdJbyW+s S/xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713843683; x=1714448483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zk8sHHlFZ5yMas0e7wt0QxJKNRueI84ut/8EKgUk1gU=; b=sfSSq8/MRHuW/cUvbNDSDFRNYskVApr2gDIZf4FjUFjDLpQ0vnPeVBufOCAG2JTpu1 BF3rsFyyRtYTBFU6rou3kqQuuWJklx4Z6L3Fq1G9HU19E7bgSS9Vme3IaJ/EmlJnl3+P ka3CbUyDJ7eHIwNVt8GdL2hBbZwZ3mRWZVr96/ywpDzv7bDdsZBX3PTg+RzDX5s2RYIT 4UVrmN2VnUsaMqi2WLGEAEzrk9+xXEf52lI96aiiuUmJR24vd16c9q5GkHFmWMvk7gJC IIn/cvSnGqa/qb4ffTkbgj4+z0E65NK1bDz5mDTDKmBAk5BEq7aRV9dra3BTMb7mVuXe EovA== X-Gm-Message-State: AOJu0Yzz+gQG+3Sc/A+GY1DcpGSLYnXTlg7dHZ5T7UX2iXaqq+oUvQsT uAY5UmMwaGYRHL70K6e6dib8X/3ly6geEftflRVgAP7sO6utQQ1aOVnoklgg7NHibE2NI2u9/mt H X-Received: by 2002:a92:c267:0:b0:36a:fe86:5fcc with SMTP id h7-20020a92c267000000b0036afe865fccmr16168240ild.0.1713843683557; Mon, 22 Apr 2024 20:41:23 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id b16-20020a63d810000000b005e438fe702dsm8266980pgh.65.2024.04.22.20.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 20:41:23 -0700 (PDT) From: zhenwei pi To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux.dev Cc: mst@redhat.com, david@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, akpm@linux-foundation.org, zhenwei pi Subject: [PATCH v3 2/4] virtio_balloon: introduce oom-kill invocations Date: Tue, 23 Apr 2024 11:41:07 +0800 Message-Id: <20240423034109.1552866-3-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240423034109.1552866-1-pizhenwei@bytedance.com> References: <20240423034109.1552866-1-pizhenwei@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When the guest OS runs under critical memory pressure, the guest starts to kill processes. A guest monitor agent may scan 'oom_kill' from /proc/vmstat, and reports the OOM KILL event. However, the agent may be killed and we will loss this critical event(and the later events). For now we can also grep for magic words in guest kernel log from host side. Rather than this unstable way, virtio balloon reports OOM-KILL invocations instead. Acked-by: David Hildenbrand Signed-off-by: zhenwei pi --- drivers/virtio/virtio_balloon.c | 1 + include/uapi/linux/virtio_balloon.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 1710e3098ecd..f7a47eaa0936 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -330,6 +330,7 @@ static inline unsigned int update_balloon_vm_stats(struct virtio_balloon *vb) pages_to_bytes(events[PSWPOUT])); update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]); update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]); + update_stat(vb, idx++, VIRTIO_BALLOON_S_OOM_KILL, events[OOM_KILL]); #ifdef CONFIG_HUGETLB_PAGE update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC, diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index ddaa45e723c4..b17bbe033697 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h @@ -71,7 +71,8 @@ struct virtio_balloon_config { #define VIRTIO_BALLOON_S_CACHES 7 /* Disk caches */ #define VIRTIO_BALLOON_S_HTLB_PGALLOC 8 /* Hugetlb page allocations */ #define VIRTIO_BALLOON_S_HTLB_PGFAIL 9 /* Hugetlb page allocation failures */ -#define VIRTIO_BALLOON_S_NR 10 +#define VIRTIO_BALLOON_S_OOM_KILL 10 /* OOM killer invocations */ +#define VIRTIO_BALLOON_S_NR 11 #define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \ VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \ @@ -83,7 +84,8 @@ struct virtio_balloon_config { VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \ VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \ VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \ - VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ + VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures", \ + VIRTIO_BALLOON_S_NAMES_prefix "oom-kills" \ } #define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("") -- 2.34.1