Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2071534imn; Mon, 1 Aug 2022 10:04:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR69WKMOGjvqbaAFiqklc1spasv2nW6Oa6YzkUspH3a9ncSXMnwLLVCxd558hARb63qASA+n X-Received: by 2002:a17:902:7c0d:b0:16d:500b:1255 with SMTP id x13-20020a1709027c0d00b0016d500b1255mr17892757pll.98.1659373477059; Mon, 01 Aug 2022 10:04:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1659373477; cv=pass; d=google.com; s=arc-20160816; b=loYcjFtvd7XLLV3ReqahYKvt+Lp1LnDG88r3c9EBIXW2TQKpXIXFB4ATLoIL8B9qGe zJv8FAK2umiMyUPV4iEirbuqo6RbFOPRnJUyslfDUPe9BexavqrV9BkZ8/Tn2sRoySSS cvn5xll2YpnhdX1sfRloC6iGLK3Mk5wbns94CQGp8GmghR2dd3FRcivQO3EzpspEaRZE F9/Dn+A5ppS2mJVhsIeD9y8Gjr5BfAgxF7JeCRnRveqevX9rB6C2KSZWMCSVoWjwZt6v Hg08ciae6vuLhCvlfV6p84/ubJHhoxiTO69SSgdudEsRiWR7mBAgVjoKvZHzEf06wwmp kF/A== 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=xyB3vd1N/O1CquFTY6hOkRNyMSTGQJTh6MET7EwJtGo=; b=dbGwgSF8Rm172LQuG6Pd1OloibpeRoryFOEB//IB/eW0ccuOSbQHZa2Uq7ndBzRIP/ 4mDciINKHMe3pDMf76FnCMumy0SiRLcgTyPn3+QoFD1iRmQble/mWB/4r7hqxonDSAFm ucdhA1+72kkn13HjIVov4135rnkKVC1fp6LpXX+2bSFaSAWoydh7K5rUeV9AhFhYP5kZ KV6pis7cdot/r1xwUszHLWRuwVE28eC0TyJt2L/BjPjzH9vYsrIC22LaKGxCNZ0Y2aK4 U8UAHUyXt1/8JHe5ZSa7JeJBwZF2RJXadk01hXN9/oJU0FLkhK5b4Ga69wHYt4/PoEjG 367g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b=uCqfIGTI; 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 q65-20020a632a44000000b004197e33daf5si13924187pgq.863.2022.08.01.10.04.21; Mon, 01 Aug 2022 10:04:37 -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=uCqfIGTI; 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 S232503AbiHAQer (ORCPT + 99 others); Mon, 1 Aug 2022 12:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232304AbiHAQen (ORCPT ); Mon, 1 Aug 2022 12:34:43 -0400 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00113.outbound.protection.outlook.com [40.107.0.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC3F3DF02 for ; Mon, 1 Aug 2022 09:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NGrOeLBOnMBZD6QiwPJSjJtna2LmxOJ668uPvCxILOT6rv3gxbyHvEvQfh2IoSiKs1wPf3iVClKpJ59++85TkhwJ/cJQMS3ozMFySrRl5XEOwa9jFx1jomSzWGvuVInm1Nrl9sZBpu8FrcbaquLT2DhQDsaQAC8rROScMeUBl/MXnxgII0JVvzshFJqglSZDtNnvllRNLVfokKG4pw9Y7TEAcPLUdgXlv2kfK66UDPImknKvRw6qgTZoVHxVa+ixB0TE4Xfj8E/iTKL/mO8/28gJ/GVrpmvO/xe1ilTo3ZywrMH/mTVVfDDUFOOKhbM/GraJ6UunTlvQahZxLbDKQg== 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=xyB3vd1N/O1CquFTY6hOkRNyMSTGQJTh6MET7EwJtGo=; b=dZrOASn4jDcqp30zlk4H4PlZVarSG6Dgk1cnytYwz3EE+pcc3KcWEkAFjEIHhSSlWarUBp2gODfpjOIwJNORt2mCGCyaZMBJlbEacey5Q1bfGKrFbZsgw2Ct7NYajcqK2xUEDFtcAo4xDM8ijjCUhDF48/m/9i4EAThowy94c+12jiyH4uUF90+yg0A9zb4OmT6kuvlxKhKhMASog100kc/epWiMwMNSlXGpQqCOIuHOw8SDwy147Gz57aIljzKrJ3wHdLnHGWMszDwSwQaXTYLb5RXPMFotohtW242e8A9DotUJmZcUWgOhO5wi6ymdc6Jyya1FJre1/CIrB+hePg== 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=xyB3vd1N/O1CquFTY6hOkRNyMSTGQJTh6MET7EwJtGo=; b=uCqfIGTIzSIb1hcwwo1peB/J8r1gLeB63PI1NBuJvCVttoVpzHr7sMxqCMra931rSHkFUb0etGAuy7iEHYXDrifQTowzn84jyL9jonvZvI8h8xq2XfrGfwPb3DpjtA/VX2k/jrhgz7TcT/6gW78ufkCMtMUjOYi2CtEwP72G+RymKFl53wQ3AJi/YRwsTO3ba5VpAFePT/9f2VeOotdSnc1nSf/RVR5ROhKobKNIbd80/23gYaMbvn9WTB8awgs8zij92SE2vptAmJP/t6OJsCDJFTM3DYoQqCo9oOWM2STxj3BaOiU4S3gbp8dHunY36UnqML+YBgfUVTXca4toQw== 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 AM6PR08MB5128.eurprd08.prod.outlook.com (2603:10a6:20b:e3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12; Mon, 1 Aug 2022 16:34:38 +0000 Received: from VE1PR08MB4765.eurprd08.prod.outlook.com ([fe80::cce4:bfef:99c9:9841]) by VE1PR08MB4765.eurprd08.prod.outlook.com ([fe80::cce4:bfef:99c9:9841%5]) with mapi id 15.20.5482.016; Mon, 1 Aug 2022 16:34:38 +0000 Message-ID: <3a5e60e8-a0d2-a1f1-28e9-e0b45069029a@virtuozzo.com> Date: Mon, 1 Aug 2022 19:34:36 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v6 1/2] Create debugfs file with virtio balloon usage information Content-Language: en-US To: David Hildenbrand , "Michael S. Tsirkin" , Jason Wang Cc: kernel@openvz.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <55016ed9-7b3c-c4eb-f5f4-02cfce2191e4@redhat.com> <20220726140831.72816-1-alexander.atanasov@virtuozzo.com> <2d0703da-ae89-7002-f500-300a4b5d206b@redhat.com> From: Alexander Atanasov In-Reply-To: <2d0703da-ae89-7002-f500-300a4b5d206b@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: ZR0P278CA0161.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::19) 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: 3eba273d-f899-49f9-2ec2-08da73dbba19 X-MS-TrafficTypeDiagnostic: AM6PR08MB5128:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9mmpeNWh6y1zsR6CC6nynJx6rnwE2QAb3d/KUoWgjsKbP6OqAQF7q7QHJlGz8QXcz1f4QYlChSY2bZa74Y84PQ2tjjDgaJOY3ru0cI/2Dsx9g9CSuBvLMiZ9RZRJjEF179T1q6R48n1CnO7LiE0x8Vo82xUB2ohQ+g73ipFjkO7A4zp6YwUOh7H4RT9SZo4bEbR6UqTNKXtiBMajBtNMGUbzIfx3Lo+1Lt5kYLwzG5McymkTuYnRtAtIXC3D6O2HBrcfj4TVEUZbVrliexZe2JywEMC5sw2ukMXIZ0Fae+dKyNfYvaRWbk27tKGdJPms+SgsqblpWKJPDytGC3Hf/PDongKLePKhd9svXHor42yqzYyAi5EOssKINuWEFchkNHq5MSPmU3ufPnY26ZgxLvjGuUcACBgfN0u5DZTCIGRLOSlBBpEnjr7pLz0PVPH+LRYWth26O9qm2Dq0l/+1Ka5GNz+k0/5E7fpgCN3OEn4GrJLK1xt5uvaL6NpaH0hv/ThekMaIoojUIAuQk7FaRu8tTwr/AYaVGZHLBVrIa6V+uELHvKZNVjqApzJwC7qZH0A/Gh7A4azVpLG7nb1FJ/q/9MNUiMNqI7DKfEex5WJm2Jwh/boysUDoH3Lroh4jFp62DHpW307qpRn2twP9PI9A4Ygp9SVy+svCODhpoxwJZ42rJpTyCyfx1c0lqIi0Rg3vcSAAtXalgELRLTlPMtQDIrRJUkA2mefLiYHl2rk4GO11QWdlx4/5QuabdCcNTsbcoJA7nrKgOD6V1JiWKWfahnSJgPtS2VURiSikaBXkZLGLAOUuNSI93PHYXrOQ1oFKz65l926aKE/cLmSYN4SjlN+jmk458LcAZP5jeyE= 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)(346002)(366004)(136003)(376002)(396003)(39850400004)(66476007)(31686004)(4326008)(66946007)(44832011)(66556008)(5660300002)(36756003)(41300700001)(316002)(110136005)(8676002)(478600001)(8936002)(6486002)(2906002)(6512007)(2616005)(26005)(186003)(6506007)(53546011)(52116002)(83380400001)(31696002)(38100700002)(38350700002)(86362001)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aU93bjlKcjFveTJvNWc0aXJldHdKTjJqYjFDV0ZPNEpSamlabk44S00zNFV0?= =?utf-8?B?SHBLcVRpalVscDJmeXIzNTBFbmxGZ0lLZWRwQ3NZUnZkRHlHSzhHYWY2bkZo?= =?utf-8?B?UzR0QUwyY2dCTStIdVRQYUYzQW9ZVEludVFvY1BtZkdpZXAzUE05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swbHdJL1JCbUpLOUY4QUdiWXEyUWpFdW51K1hmOE9KeGVYSW9mQnF0?= =?utf-8?B?MzJLYUJUai84bnVDYTRoa3JpYWVMUWtrakN6NkY0NjhIT3NTUkhERmJHcWpX?= =?utf-8?B?UnR1OUFmZ01Uc00rM3Z4VFBwd2dvanIzRTlUNkdyVE40WnRUVXphRkt6Uk90?= =?utf-8?B?bmx6OGVEaDlQcXIyWVp2VlFvWFdSMHlBQzB3amdwVno4cVdhY0swVk1oakxu?= =?utf-8?B?dEE9PQ==?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3eba273d-f899-49f9-2ec2-08da73dbba19 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4765.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 16:34:38.4528 (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: 2gjaW8fFHJayiE7iVghQpmeU+7oCtk5GxEtTuqaivMRgOgxmjvQAFXk+22+BFn+/rmsZkM41W9kWSc6HlUwq3yqbEaIoRmRxZtxRuai0YDShOyo9KtD+igziMJH4DmoP X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5128 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 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 On 01/08/2022 18:18, David Hildenbrand wrote: > On 26.07.22 16:08, Alexander Atanasov wrote: >> Allow the guest to know how much it is ballooned by the host >> and how that memory is accounted. >> >> It is useful when debugging out of memory conditions, >> as well for userspace processes that monitor the memory pressure >> and for nested virtualization. >> >> Depending on the deflate on oom flag memory is accounted in two ways. >> If the flag is set the inflated pages are accounted as used memory. >> If the flag is not set the inflated pages are substracted from totalram. >> To make clear how are inflated pages accounted sign prefix the value. >> Where negative means substracted from totalram and positive means >> they are accounted as used. >> >> Signed-off-by: Alexander Atanasov >> --- >> drivers/virtio/virtio_balloon.c | 59 +++++++++++++++++++++++++++++++++ >> 1 file changed, 59 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 >> V5: >> - Made the calculatons work properly for both ways of memory accounting >> with or without deflate_on_oom >> - dropped comment >> V6: >> - reduced the file to minimum >> - unify accounting >> >> I didn't understand if you agree to change the accounting to be the same >> so following part 2 is about it. >> >> >> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c >> index f4c34a2a6b8e..97d3b29cb9f1 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,59 @@ static void report_free_page_func(struct work_struct *work) >> } >> } >> >> +/* >> + * DEBUGFS Interface >> + */ >> +#ifdef CONFIG_DEBUG_FS >> + >> +/** >> + * 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. >> + */ >> + > Superfluous empty line. Personally, I'd just get rid of this > (comparatively obvious) documentation completely. Ok. > >> +static int virtio_balloon_debug_show(struct seq_file *f, void *offset) >> +{ >> + struct virtio_balloon *vb = f->private; >> + s64 num_pages = vb->num_pages << (VIRTIO_BALLOON_PFN_SHIFT - 10); > Rather call this "inflated_kb" then, it's no longer "pages". Ok. > >> + >> + if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) >> + num_pages = -num_pages; > With VIRTIO_BALLOON_F_DEFLATE_ON_OOM this will now always report "0". > > which would be the same as "num_pages = 0;" and would deserve a comment > explaining why we don't indicate that as "inflated: ". > > Thanks. Except if "now" refers to some commit that i am missing it does not report 0. with qemu-system-x86_64 -enable-kvm -device virtio-balloon,id=balloon0,deflate-on-oom=on,notify_on_empty=on,page-per-vq=on -m 3G .... / # cat /sys/kernel/debug/virtio-balloon inflated: 0 kB / # QEMU 4.2.1 monitor - type 'help' for more information (qemu) balloon 1024 (qemu) / # cat /sys/kernel/debug/virtio-balloon inflated: 2097152 kB / # with qemu-system-x86_64  -enable-kvm -device virtio-balloon,id=balloon0,deflate-on-oom=off,notify_on_empty=on,page-per-vq=on -m 3G ... / # cat /sys/kernel/debug/virtio-balloon inflated: 0 kB / # QEMU 4.2.1 monitor - type 'help' for more information (qemu) balloon 1024 (qemu) / # cat /sys/kernel/debug/virtio-balloon inflated: -2097152 kB To join the threads: >> Always account inflated memory as used for both cases - with and >> without deflate on oom. Do not change total ram which can confuse >> userspace and users. > Sorry, but NAK. Ok. > This would affect existing users / user space / balloon stats. For example > HV just recently switch to properly using adjust_managed_page_count() I am wondering what's the rationale behind this i have never seen such users that expect it to work like this. Do you have any pointers to such users, so i can understood why they do so ? -- Regards, Alexander Atanasov