Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2093407lqt; Mon, 22 Apr 2024 00:44:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUsGWmNRk5QqI0OAFpB+BdglCStM5hDtHs3CDGtHgagrJ562YUB63HEg1rkFgmbUDd5lr9MDjpfE6pugnOyi0xDgG0tbMWzBV1Li4eCOg== X-Google-Smtp-Source: AGHT+IEDCGuh9NgGOYlGmi9XtMG/L6gW2/VM+gdpxrc8duBHsZPamfbNM5BVwFHpZsbcA+Dvn1OO X-Received: by 2002:a17:90b:1f88:b0:2ac:df39:4224 with SMTP id so8-20020a17090b1f8800b002acdf394224mr4111387pjb.28.1713771879930; Mon, 22 Apr 2024 00:44:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713771879; cv=pass; d=google.com; s=arc-20160816; b=EqK2bpJz9hZbiZ7PWpwTSk+VWQK9B8BFaiDLafK8v8ufIT6k4WBbpB5AC4YtNhqS5U iI/CT14tE6+0xVz5bNw5yj3bPImZbsy47EuWLOj67J2hhX/D3Ls3WPQ40MBIKFp2R2Bu K4g4VvKi5aS7UV1zrInv16PJasU+GVnrR27UttjXueNNOwPdGxw+iZLkZPDEvjECaRRX +J79JhJySLAw6XoNvxBgvodiL+XKOPSD/BVPeg3t8sg+arBgBHwy2PtlUAugrZmh8j7N A2QRq5kyr4bNr0OE+KOnruDTl/LJDK7PT7ZELlM1EHjwZquv7zitcAAwvs3roZ4xo+mv K6cw== 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=zrl4akKhVgEJxLJYwq5+gLRsb/mo5Xi0vTQ5EYuojH0=; fh=8j3cshPcKC8dh7LNhAimwJd791iUI4B10zfUQz02DzE=; b=aUPv033TtQ5HS9iUKnrHgAYOwX0YPb7v5mBWgE3zBabDKYOz+E8KgimPgKGn+t9PHD Vjm+AtTttRTBzKMZ6XkI32D4K3JmtH/lOECGiuXfiTiBUnPaGyn8sWfg/cDtRQYE/R9F 7w0gPaTLpr61Ba6EuZrGSinflydIHqZelxm97amE2YiQHOUWH6phjkfpgHTHQAe62Jue JnjfkWNBdgGrBMMb+n57UOGcuNrp9MWDeVDk/xnV0ocYFnqKDRCp/uDgClo2oZB4I2AO ZrgvxHOFcNa51jE040Q2x8IFMxKzBSFnEVL8D79xPH/8QT+KhEg20z8diAglnGkD3pg3 a8VQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=TajcPByk; 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-152891-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152891-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a22-20020a17090acb9600b0029de97229e8si8900276pju.189.2024.04.22.00.44.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:44:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152891-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=TajcPByk; 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-152891-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152891-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8FAB7283EA8 for ; Mon, 22 Apr 2024 07:44:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 445834D135; Mon, 22 Apr 2024 07:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="TajcPByk" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 EC3CF502A4 for ; Mon, 22 Apr 2024 07:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713771794; cv=none; b=YKiLS1zcRMcUPrJO4k2GNqCmDpypFXkK5VHcu87+N3JsYpdQKBWLA2YITbXP+vpaLjhQKZmjKGnrEU2gurrBWrah143symwUIEcKG3u3ahh3TmMsIO9uaUS8STV/CKofY60htFvpugZUvI65hLF7FVD252pUCknx6WBmxvUt8oA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713771794; c=relaxed/simple; bh=Tifl00pi8az9qD8WZxeEmmg/browFVnK/hcBZYXoc2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uMPuZmtHFfULP5xXzQJCG/A0A6bPdqtPCRty6oIH6wyFr3nSf3BCm/9cvjX+pkOpPgDXEjVMf1tHbSm8xqMQN0IKGto0Q5FFQilYT5IDmjagvpf9i4xv+ldcM+8wjZPcIxUzkbMT7Iz7yKtaULXHg82uaesQcxEwIIXkqfIlOmU= 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=TajcPByk; arc=none smtp.client-ip=209.85.214.169 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-pl1-f169.google.com with SMTP id d9443c01a7336-1e2bbc2048eso33640975ad.3 for ; Mon, 22 Apr 2024 00:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1713771792; x=1714376592; 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=zrl4akKhVgEJxLJYwq5+gLRsb/mo5Xi0vTQ5EYuojH0=; b=TajcPBykzMV0eL9dLEJzwK4tSkjkhUlb+1GJCEKbUfsiz9/1tFOGOSQdyIRkrK6EwR N8uJW6oXfym0FiLE7W3mnioTQMVWIrONt3kBEgH5pCY042GKYJ7hsQ+amXmAAqrqk9pj rbIo3S2z2oiTEUV3pGQiqEsZ6S8v1UYYxZWDa4+xQaBMa4oDODNgMjOAaq7GquZZHTu/ wGUN/f/A3ikRl4r9ZC65b9mH6CAl8kdwhIFT5eLhruReXkT2ta3qfe2cwrcDD5PQZRsn 5+xZFV/vJqfWyPR1/Rx6IOHdJWF6ozeqhqYIpylPpqBoKVenns5kqBTreMataC1zSKpf BDjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713771792; x=1714376592; 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=zrl4akKhVgEJxLJYwq5+gLRsb/mo5Xi0vTQ5EYuojH0=; b=l6FAy8Moa4dmnTJaeInt5fMZgY950t00VQSjEvMvVgnXoQr0yitS5goK25Iydc5PdW zUYk1bMUWOPL4WBNhQc4+n6BVBQBN1G2m80KQVWAN4Fn9lWp9XUsPbE3c8PYVCuvXcym tixKvUH+knCEBxQxhk9fxXBf58GC9rBN+tBNcvyKmOKeGo9tkLCQebKN0XsRvIASYgI6 brLWXh2Yv8IxWEkT/zE1oYtYtGJD3BYmwrZ5QI0xTIlEzZ15QJUGTn2YTUsvW0+BW/rL AyRBM0x5rpf2eU07OAbIs/IqEvsKhn2TwLs54XVuInkx1+3BqCH7GFg0lMHA3CKCmrCw RYNg== X-Gm-Message-State: AOJu0YzFljzxaPRDY10FHBlzV19HU7sqMvse7IGZ2tRt9s/RoLA9Wnp4 FOZJW1fddnha10qY9D6CVgj0VDA91WwRvWGJIprd9i38IczEUNDzywxFK/eTZWqhzH5AxoW2mw3 a X-Received: by 2002:a17:902:db07:b0:1e4:bd90:f1d4 with SMTP id m7-20020a170902db0700b001e4bd90f1d4mr11064583plx.40.1713771792141; Mon, 22 Apr 2024 00:43:12 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id e11-20020a170902784b00b001e0bae4490fsm7595634pln.154.2024.04.22.00.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:43:11 -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 v2 3/4] virtio_balloon: introduce memory allocation stall counter Date: Mon, 22 Apr 2024 15:42:53 +0800 Message-Id: <20240422074254.1440457-4-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240422074254.1440457-1-pizhenwei@bytedance.com> References: <20240422074254.1440457-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 Memory allocation stall counter represents the performance/latency of memory allocation, expose this counter to the host side by virtio balloon device via out-of-bound way. Signed-off-by: zhenwei pi --- drivers/virtio/virtio_balloon.c | 8 ++++++++ include/uapi/linux/virtio_balloon.h | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 87a1d6fa77fb..ab039e83bc6f 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -323,6 +323,8 @@ static inline unsigned int update_balloon_vm_stats(struct virtio_balloon *vb, #ifdef CONFIG_VM_EVENT_COUNTERS unsigned long events[NR_VM_EVENT_ITEMS]; unsigned int idx = start; + unsigned int zid; + unsigned long stall = 0; all_vm_events(events); update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, @@ -333,6 +335,12 @@ static inline unsigned int update_balloon_vm_stats(struct virtio_balloon *vb, update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]); update_stat(vb, idx++, VIRTIO_BALLOON_S_OOM_KILL, events[OOM_KILL]); + /* sum all the stall events */ + for (zid = 0; zid < MAX_NR_ZONES; zid++) + stall += events[ALLOCSTALL_NORMAL - ZONE_NORMAL + zid]; + + update_stat(vb, idx++, VIRTIO_BALLOON_S_ALLOC_STALL, stall); + #ifdef CONFIG_HUGETLB_PAGE update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC, events[HTLB_BUDDY_PGALLOC]); diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index b17bbe033697..487b893a160e 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h @@ -72,7 +72,8 @@ struct virtio_balloon_config { #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_OOM_KILL 10 /* OOM killer invocations */ -#define VIRTIO_BALLOON_S_NR 11 +#define VIRTIO_BALLOON_S_ALLOC_STALL 11 /* Stall count of memory allocatoin */ +#define VIRTIO_BALLOON_S_NR 12 #define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \ VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \ @@ -85,7 +86,8 @@ struct virtio_balloon_config { 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 "oom-kills" \ + VIRTIO_BALLOON_S_NAMES_prefix "oom-kills", \ + VIRTIO_BALLOON_S_NAMES_prefix "alloc-stalls" \ } #define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("") -- 2.34.1