Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1030658imw; Tue, 5 Jul 2022 02:30:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uwmVySlx7hF/VVR61wGYOFRVCAXZVpFo3os0WlFqSZlTIC/P+4weCvXZg3ghbrxPeTkcED X-Received: by 2002:a65:6b8a:0:b0:3fc:4c06:8a8d with SMTP id d10-20020a656b8a000000b003fc4c068a8dmr28589582pgw.83.1657013440451; Tue, 05 Jul 2022 02:30:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657013440; cv=pass; d=google.com; s=arc-20160816; b=BvhRAKnhPvkSsujVRJ+CHpSLkB+AZTMY7LtwJJqSfm5/NKWWVEwTN+c+OUEaH/+8qF 1A6Mr+A8iinuOcMo+AIztsuTvUwIGgYITvPH60TNdQeEt/O3EmXX0Urkt+8dqWN/LHin pswxk7V5+d5EhMVmXsS48FmxSurcqPsiXsQcToBPpaBmX2uc1komDyNCVwmLOeG7kql9 AW9Huz1edniz/EeaBDtsDvJ+6TfrxqpbVSEYK1l9b2QACqALvRfSTZrxcyBumNra2mh1 YibCHKOIb3u8+fl4vsOhg9sehVDw77iuWLLMKU3HWIxR8jNkrvCL6xrbzDNxPYJPr06g ytdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=qxACyF5oi8TbIic8mkM/J/U1qFcTYr9lpIEtBzy/zzQ=; b=RBImuPnJJ7gu9oAX40VsbQPGlByixRjJTILVLDtyC4ZxN68OGBQfbH0BgixRpn/yw+ BpC/c+j3qJRd3aAgKEKpiJLDfUS+Ow2JYOKd50vdCze6lWe05ovoM5o9nf2m6ZS7PlXQ vSAA/0NHcsS6dFc0LnsAIIDvEb8G3BYtHWKPSt6lG5CM8yLLjKAYfQhPP99Bo+tFxhbZ mCm9U3nptcjxGPr7jpvV+1WpYhJP3gVMo+cvraIXGFZIV9xeVKc7uBdYCS8VAvN4Cu9R uaU062hQbffkdDW00v+bpW1aZsWIfofhoO2qpnF0oqUtdMq8lak1UwboOPl9yYZLtI/T 1DUQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b=XSffP4BE; arc=pass (i=1 spf=pass spfdomain=virtuozzo.com dkim=pass dkdomain=virtuozzo.com dmarc=pass fromdomain=virtuozzo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020a170902aa8e00b0016a147b8f68si9828783plr.177.2022.07.05.02.30.26; Tue, 05 Jul 2022 02:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b=XSffP4BE; arc=pass (i=1 spf=pass spfdomain=virtuozzo.com dkim=pass dkdomain=virtuozzo.com dmarc=pass fromdomain=virtuozzo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229844AbiGEJDG (ORCPT + 99 others); Tue, 5 Jul 2022 05:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232298AbiGEJCq (ORCPT ); Tue, 5 Jul 2022 05:02:46 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130134.outbound.protection.outlook.com [40.107.13.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1E1392 for ; Tue, 5 Jul 2022 02:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IBRayz78frcfc6q9b082rw4+nu3jGjfM3mBZRStB3ZyRFPVnCkLcPoGjjY4BWeUsxAebxYMk2pnd8tqmwRzYkeCo7KTX8HKa8bZJ//3l9BsFWZJqmaeMuK9+/0H7433DbVO58we/1zaQcK9PzLs6ub4SEm4TJs5bN4gjp0AyqpC6kV/pnWWPZd8TGIUAf6AH/3p6oPws0kyy3skRlQxbPDRGVRMGF3+NZ6ZrcsGm13uGGxWV2RK0FarHzOXwzxANmhKoH+pX9H70j78PGp5eq391c1E3G608NJM+LjeDDJ56wGnkT2eHEJZsiRGKt7nMReHZBVwm4G6G05bJ3i//Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qxACyF5oi8TbIic8mkM/J/U1qFcTYr9lpIEtBzy/zzQ=; b=RSiQSITIUpEZxmVvTU+YkACwHI3MqQeAdsev/nLs14Cy0KhSpOj/0aMNgDREGc4/SZvBZQHKiNMohH5XmuyyaEhaN1oyRJDUoiXxRZtMe9nWUVTjEKCfMVkmw4XbVy0gzWt6VBxrsjxCiNlRhM2pVDJZcTs9V0bqF0QTJB3bfMzk2+7UkHWp4kruW8tpJzgi8KfTuoiD6B6pZEHhcfrJjcSTLDIwKtoGhPSpg9OAcnqbpjC4k59FiWlACnrOZbBXbP7e2GGjdwYB8nXj5d2xpEmnZG+dRbt3e7G1KOircWA5tLCf8z/DQbVn3nHZB5P7h9npiAwRcVsdDt5Rp4gK4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qxACyF5oi8TbIic8mkM/J/U1qFcTYr9lpIEtBzy/zzQ=; b=XSffP4BEuH1GdvOxVeiiRjIofuERxoY009kZXD6es/r63WxO9CltqHK6U3HLEost6T/0I/SNZL5CLQ8ZiFnazgkbaDbfdfEiO3Ck0QXHYji6igMq2eqOGyeN/iTSeg7odZAi/kcvF/JBUrABNBDACAY/Gxo8a7WCl1YlSEZqVuA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from VE1PR08MB4765.eurprd08.prod.outlook.com (2603:10a6:802:a5::16) by PA4PR08MB6141.eurprd08.prod.outlook.com (2603:10a6:102:f2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Tue, 5 Jul 2022 09:02:00 +0000 Received: from VE1PR08MB4765.eurprd08.prod.outlook.com ([fe80::2d53:2023:e29a:cf48]) by VE1PR08MB4765.eurprd08.prod.outlook.com ([fe80::2d53:2023:e29a:cf48%6]) with mapi id 15.20.5395.021; Tue, 5 Jul 2022 09:02:00 +0000 Message-ID: Date: Tue, 5 Jul 2022 12:01:58 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v4 1/1] Create debugfs file with virtio balloon usage information Content-Language: en-US To: "Michael S. Tsirkin" Cc: David Hildenbrand , Jason Wang , kernel@openvz.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20220705083638.29669-1-alexander.atanasov@virtuozzo.com> <20220705045912-mutt-send-email-mst@kernel.org> From: Alexander Atanasov In-Reply-To: <20220705045912-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: VE1PR03CA0033.eurprd03.prod.outlook.com (2603:10a6:803:118::22) To VE1PR08MB4765.eurprd08.prod.outlook.com (2603:10a6:802:a5::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6006916-26f2-4770-b33a-08da5e650554 X-MS-TrafficTypeDiagnostic: PA4PR08MB6141:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +YjDBK7kTXM2eq93+gbfKyLx2IdDl+xi7BNgx2+3UwT8jlW1HwwtBHK/fFQ9vQgQ2y3/J/baqtdPOhEVgQ2DHt/GOxsZ1P7FoLdlBw83lAe6IldWBqsj10M+dcDos9hO91xVLoq3XfbxzYqOmIbMrVtVk1Jvq5kCR/0Ew3QvFOqnohTObi4BXYa+48EbdSouxh3bZ0VgA1dmey7vr2FkGTE18pveQXjnrZrMiplb3Z9IAKPhlT2Q4C0Hmpy4hLoUYd5EC4XRqa2JqdtgJTs/thyhMJLMylz0cIOGYA3J78zv6T22Hy6bDN4pRydxOTpbSeUim28NPhn/ABOv46hIyUU8APg3axu1Mr6PvFPkdXku2rBB2Zzb7oyXqMpu+DXXsFodnhMYye+7ieHR3Azp9JYZhIIVnn1FYs92qmvIIgSY0KLhDbiMQ5qGvtNHjoskZGpJN1iqO7MG0KtlqhivphUVTiI7OaLyr7h8oE24f8KO1llcIUzIUBVaSBEosERTLQ7+LRYWQjZufUJWxOJPGTL/gAaqeOahNpdU+NM7N874cDLDgJQmNT833wCeKKNff05QuSPhNh2Bm46PdAAIQ6fW6zjW4/Avnz32TMdUIB1ZzQLhNthM7XKJq4wZH8QP2jplwOD8m3Ml9OQ+9Wd7SLASOJi17LX0jZRk1S6in0BLr8AnpB1XT7IyZUHy6odz+2C+UIAwaotkJ2AanKtaqATaGoRgBq7n38WxWXDj4yqqwRgEOiRpBqpFRLim6nv8Mm8iDx2uzQx0XMIEcjfAaUYXH0VbbSh0mzOTdZTX6DYaacGE2lNBQKpwBOCA6BuhIaK/7apTPdBg3BfislIapHehK6qVmyZxzRLpAsPJu+588fdBEfpa8bOwKq5caxLG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4765.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(39850400004)(366004)(396003)(376002)(346002)(44832011)(6486002)(478600001)(8936002)(5660300002)(52116002)(53546011)(6506007)(31696002)(6512007)(41300700001)(2906002)(26005)(86362001)(38350700002)(38100700002)(2616005)(186003)(83380400001)(66946007)(8676002)(66476007)(4326008)(66556008)(36756003)(31686004)(316002)(6916009)(54906003)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VElyTDRsWTVmRTlxVTNLSnhTcnZlMVlmYjJiazZKR0gzbXNaMG5WVnAzL1BL?= =?utf-8?B?cTZoeldDWDg0UlZEYTlzbGF5VVZra0J2c1BtNWNBd3pHRWlNWCtwcWpxSGVK?= =?utf-8?B?UFMwa2tsYnU5SXNzcE1iT3dMOXB4MzBXSTZnVmZ5ckx5eGoxR1RkODl3U0c5?= =?utf-8?B?VFdkdFN3S0lJaG94K2RHbWY2MnRRTlExLzhrM1QrbEVPbm5qSVVIdjBGc1pv?= =?utf-8?B?YTdpeHVMRWRNQWJKMWhUanpVZk9oWjV2b3VwQk5ZM1RvbkVEbTRZM2RSRHlh?= =?utf-8?B?STlQWVRDem5ZR2hKSjlFTWRlZm1qRjFja1Rh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3?= =?utf-8?B?S1licjc0VmxaYlVGSUtYNjRYZUV1VVd6MUpaNHlXQmJKMll0ZzVOUklNM2JN?= =?utf-8?B?OHc9PQ==?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6006916-26f2-4770-b33a-08da5e650554 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4765.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2022 09:02:00.1897 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jkB87yS4IkSen4Rlny1waaxp79homTa6shnGAxdnMtIQ1PwU1mSdhSRP8lwdOvGdYVTyTYifwnYH4rBVkbhlw85I4mawFazbF572e4/z20bURYmoIwhb1a7NoKa8cWQf X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6141 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 05/07/2022 11:59, Michael S. Tsirkin wrote: > On Tue, Jul 05, 2022 at 08:36:37AM +0000, Alexander Atanasov wrote: >> Allow the guest to know how much it is ballooned by the host. >> It is useful when debugging out of memory conditions. >> >> When host gets back memory from the guest it is accounted >> as used memory in the guest but the guest have no way to know >> how much it is actually ballooned. >> >> Signed-off-by: Alexander Atanasov >> --- >> drivers/virtio/virtio_balloon.c | 77 +++++++++++++++++++++++++++++ >> include/uapi/linux/virtio_balloon.h | 1 + >> 2 files changed, 78 insertions(+) >> >> V2: >> - fixed coding style >> - removed pretty print >> V3: >> - removed dublicate of features >> - comment about balooned_pages more clear >> - convert host pages to balloon pages >> V4: >> - added a define for BALLOON_PAGE_SIZE to make things clear >> >> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c >> index b9737da6c4dd..dc4ad584b947 100644 >> --- a/drivers/virtio/virtio_balloon.c >> +++ b/drivers/virtio/virtio_balloon.c >> @@ -10,6 +10,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -731,6 +732,77 @@ static void report_free_page_func(struct work_struct *work) >> } >> } >> >> +/* >> + * DEBUGFS Interface >> + */ >> +#ifdef CONFIG_DEBUG_FS >> + >> +#define guest_to_balloon_pages(i) ((i)*VIRTIO_BALLOON_PAGES_PER_PAGE) >> +/** >> + * virtio_balloon_debug_show - shows statistics of balloon operations. >> + * @f: pointer to the &struct seq_file. >> + * @offset: ignored. >> + * >> + * Provides the statistics that can be accessed in virtio-balloon in the debugfs. >> + * >> + * Return: zero on success or an error code. >> + */ >> + >> +static int virtio_balloon_debug_show(struct seq_file *f, void *offset) >> +{ >> + struct virtio_balloon *b = f->private; >> + u32 num_pages; >> + struct sysinfo i; >> + >> + si_meminfo(&i); >> + >> + seq_printf(f, "%-22s: %d\n", "page_size", VIRTIO_BALLOON_PAGE_SIZE); >> + >> + virtio_cread_le(b->vdev, struct virtio_balloon_config, actual, >> + &num_pages); >> + /* >> + * Pages allocated by host from the guest memory. >> + * Host inflates the balloon to get more memory. >> + * Guest needs to deflate the balloon to get more memory. >> + */ >> + seq_printf(f, "%-22s: %u\n", "ballooned_pages", num_pages); >> + >> + /* Total Memory for the guest from host */ >> + seq_printf(f, "%-22s: %lu\n", "total_pages", >> + guest_to_balloon_pages(i.totalram)); >> + >> + /* Current memory for the guest */ >> + seq_printf(f, "%-22s: %lu\n", "current_pages", >> + guest_to_balloon_pages(i.totalram) - num_pages); >> + >> + return 0; >> +} >> + >> +DEFINE_SHOW_ATTRIBUTE(virtio_balloon_debug); >> + >> +static void virtio_balloon_debugfs_init(struct virtio_balloon *b) >> +{ >> + debugfs_create_file("virtio-balloon", 0444, NULL, b, >> + &virtio_balloon_debug_fops); >> +} >> + >> +static void virtio_balloon_debugfs_exit(struct virtio_balloon *b) >> +{ >> + debugfs_remove(debugfs_lookup("virtio-balloon", NULL)); >> +} >> + >> +#else >> + >> +static inline void virtio_balloon_debugfs_init(struct virtio_balloon *b) >> +{ >> +} >> + >> +static inline void virtio_balloon_debugfs_exit(struct virtio_balloon *b) >> +{ >> +} >> + >> +#endif /* CONFIG_DEBUG_FS */ >> + >> #ifdef CONFIG_BALLOON_COMPACTION >> /* >> * virtballoon_migratepage - perform the balloon page migration on behalf of >> @@ -1019,6 +1091,9 @@ static int virtballoon_probe(struct virtio_device *vdev) >> >> if (towards_target(vb)) >> virtballoon_changed(vdev); >> + >> + virtio_balloon_debugfs_init(vb); >> + >> return 0; >> >> out_unregister_oom: >> @@ -1065,6 +1140,8 @@ static void virtballoon_remove(struct virtio_device *vdev) >> { >> struct virtio_balloon *vb = vdev->priv; >> >> + virtio_balloon_debugfs_exit(vb); >> + >> if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING)) >> page_reporting_unregister(&vb->pr_dev_info); >> if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) >> diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h >> index ddaa45e723c4..f3ff7c4e5884 100644 >> --- a/include/uapi/linux/virtio_balloon.h >> +++ b/include/uapi/linux/virtio_balloon.h >> @@ -40,6 +40,7 @@ >> >> /* Size of a PFN in the balloon interface. */ >> #define VIRTIO_BALLOON_PFN_SHIFT 12 >> +#define VIRTIO_BALLOON_PAGE_SIZE (1<> #define VIRTIO_BALLOON_CMD_ID_STOP 0 >> #define VIRTIO_BALLOON_CMD_ID_DONE 1 > Did you run checkpatch on this? Sure, i did: scripts/checkpatch.pl ../outgoing/v4-0001-Create-debugfs-file-with-virtio-balloon-usage-inf.patch total: 0 errors, 0 warnings, 108 lines checked ../outgoing/v4-0001-Create-debugfs-file-with-virtio-balloon-usage-inf.patch has no obvious style problems and is ready for submission. -- Regards, Alexander Atanasov