Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3783501iog; Tue, 28 Jun 2022 02:41:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vF5e3yVGc0eOzvLdeTeGypkl1L+YdOCu5KCNGpjPxTI5Awr4i4cYn4qC/MLsWiuuxl56Pg X-Received: by 2002:a17:90b:503:b0:1e2:f129:5135 with SMTP id r3-20020a17090b050300b001e2f1295135mr20632417pjz.22.1656409314822; Tue, 28 Jun 2022 02:41:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1656409314; cv=pass; d=google.com; s=arc-20160816; b=nlTTyDeFN0VKJbdJQwWkPB3Q++U2853mKlYCzudeU66qv6jma9ZhtH0tLsHMU+pXyI vXZluiCZPkNzqQcrqLMzvqVQB+7Y8BQ/Ya6JRoZtx+lSA/t1mkjFo17ZSsm6d136pVZ7 vrzKbqhiYOlepOmrLnE3y9/s0QyTRIc1Y9B4zrxNg903AhrM1UdaCQr2DBmlxLoY4HTm z1kytYeJvPhGubB1wMl2MwExnwFZjRro2mzUAMA3us5ZH39JjpT/UsedxAvKmqhoEJ7K KonKUJe/uMgmAz4d68osAWCjWg64VjnZjlbc8uYw9oQOHD3pkdHj6ngi7uuwFe27rY5z cCqQ== 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=vZU7TgShkxCIolXONrNJ4R5Db7+escX0r5yxhh4lMwU=; b=m0vOBJCZO0SzpnPVOw6l4aHf4X0t4MK1cRvt86ievoNi+bpiktuWiwRHZp3mPoJos+ 5BYT05IaPR98yuEKpxh9N39N6wMiqZaeHZQcnJTSNeSHI4I8E5tBag5h0DLdQ2YuJCZG TCTyCDnxnpLN0hKf2MvK1m6oo2qXYquLnG2G/sTbz6m7x3HX/u4qq2WuBIgwdfBDi+1F wT8b0Rnfrap2BIvaVZ8ifJKxtlsjL4Nhz3imP7B9wuDcwpK36oT831plp4Ny+kQ+DYIF pvixl3dt9xThX3I57mAOeDFOeOv2c4cbA01Q/gGfdphEVR2bJjmrA6mQBeu9LLLVu7lp owUw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b=OZ8RGWqW; 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 u25-20020a656719000000b003fe1eedd7e9si18056157pgf.360.2022.06.28.02.41.40; Tue, 28 Jun 2022 02:41:54 -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=OZ8RGWqW; 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 S245709AbiF1JHR (ORCPT + 99 others); Tue, 28 Jun 2022 05:07:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236430AbiF1JHP (ORCPT ); Tue, 28 Jun 2022 05:07:15 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70117.outbound.protection.outlook.com [40.107.7.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E62F1277D for ; Tue, 28 Jun 2022 02:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CqBp5HYw4wgN6jo/zte7G9oAgl1HLy3Jvv4O2ZZf7iXUOjHcpBe8iw1knSxG21rCCvwjvVYsQ+WR2vfG+JluZSdKMZ792ZCKKVM5344QLFt5aIqbSHcGx3XdNDl2yb9Fw/DtVtbmAvwhD1A37Tf/D4ycQGd6pRbtqNkH5Q4EINyBDhKXLgNSJzhPfo8K+Y/BzLPzGiAYlDzDGmKOgYlUHqPAblhZlkbrsDkBAaGgE5g5gO4FDBaTlgGYkp2pNl8jeKy6g1PQkwMiCZqtHP/yP+jtGW1vcmsMO+2k9Yt+x3pV0RcJDWNP8+fGq+2ELz7u1IU6M3Tf+lCEpZ9f8CPRFg== 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=vZU7TgShkxCIolXONrNJ4R5Db7+escX0r5yxhh4lMwU=; b=UquZ0i27vgSn73vjgvIXVd/vOgnq9295LlZ7fqdYnQW476umiWbIPOa0bXxtNNSM6XtKwANs30SQ7LkEQohiZfxqE+ucvMUorCH/AqlMlGQxap72EfrzYuLcv2nmL2DNkk45rIMRIIoNTih5l5E9Pbtj8B7MM/PYDNuRHPiwWJGGo1xuwnhQl7haNsDc3cEcZLW7Xskb1+Jm+HXmzIhZUfvQJcRvsWR+6f5Z/mgNQoW1fiKt62vx4Lk+CeXXJ/Etv/8G8y2P5ertdP8fNmtBCHC3ftsQp+x7vhV4T+uJaDGcUEwql3vMDdC3upi3sb2WGKGGA4930u+AySWapEwkjA== 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=vZU7TgShkxCIolXONrNJ4R5Db7+escX0r5yxhh4lMwU=; b=OZ8RGWqWycbbzWuiZ5AQbFGB9tuSMEyEpTExpw1jtHen+k9lgkZBg3fTZPojG01Zx+p1a34YiVEU76di52GVABdw8ZU4umGUZM5q7WczkplrooIyIPOeJ0frgX10VberUlrsPUHx7ErKxRPpLt96vSZW4L5H4ronm43DngIbCzI= 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 HE1PR0801MB1691.eurprd08.prod.outlook.com (2603:10a6:3:7b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17; Tue, 28 Jun 2022 09:07:07 +0000 Received: from VE1PR08MB4765.eurprd08.prod.outlook.com ([fe80::60dd:9fed:c95d:e54]) by VE1PR08MB4765.eurprd08.prod.outlook.com ([fe80::60dd:9fed:c95d:e54%7]) with mapi id 15.20.5373.018; Tue, 28 Jun 2022 09:07:07 +0000 Message-ID: <00e716d9-3ef8-a3b2-e1a9-26ddaadf3ea3@virtuozzo.com> Date: Tue, 28 Jun 2022 12:07:05 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 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: <20220627085838-mutt-send-email-mst@kernel.org> <20220627191910.22734-1-alexander.atanasov@virtuozzo.com> <20220627163714-mutt-send-email-mst@kernel.org> From: Alexander Atanasov In-Reply-To: <20220627163714-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: VI1PR0601CA0006.eurprd06.prod.outlook.com (2603:10a6:800:1e::16) 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: cfbab786-0d52-4148-9a92-08da58e5938b X-MS-TrafficTypeDiagnostic: HE1PR0801MB1691:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iDmfAPy3snJR8SKXIkC+McVk6+6yV8bE4jAXm3P3KA427DV1oxdu+V4DNajpw1uulAJd9ywOoo+zVKDH6JINpi/mPiqvQL+UugX0B1c2qpzkVaJpX/vtKJgToA6emzS1w8WaXF0IU15gb/VT8YAATmd9RvNSagicLCtv4ZEayXi4m3l4g+m27o0wfl4P4votta7UrkcoOs98gNGyTbOXYYQHWv9H1MaxOOYhyS4kFzlj7pvxHR4Q1Ssmy+ewyqyZ47CcIoRExJpyBlv+POEbFxckk09FSKkW5KzxsVDMXNnA+l4Oaf1hpC3YPYpoK9u9TeyXQb9pYJYvaaq49D9yLBvhDGhri4+GHI+w11Pv7p0OKeDr8oU+gjjcMLo42zsKpGrWRfwVB5I5aXgTF+zd/6uHRKlfwTQxHYUIgraA0QQLxyvvuOiAyKiNRWVuV12xH4wJuQVb/JXefME96kDC9xqyWZh7awQTS8z2zuxUTmR5jN9i9iF1ChBwgvCMV73v4/8xdlcGBvxahIBaodObngPaiks+RIFZoGFUTGorZFogWyKRk0qQS/asezIj4TwnSX7BCYMw8VBtnvZ0kvceuKydH4g9ADBhkM0tinzeXfSbcWZqtKN2KBNWM0tCNgJ3SFyvWiMFP0dtC1viZuXDT5/0TNGYpnIIKNFqCdWs53g9Yd2ewmg0Xrqecjj3IT16p+SWoAKCGOsMw4ELJV/pZLZIeUD3ZRixUjSyN5Jkuude/Vh5WeUvH1n2jDowNJ/8BO39OhWKR5FOt+rfx9a22H8FCKyaMyv6Xb136ZpN6SaBQ8Zok5yjxzhlCo01mIftwjUJ4306e0Ae26c7UiLXy+2sMfXtKPpWCSJhXh1DbLU= 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)(396003)(366004)(346002)(376002)(39850400004)(136003)(52116002)(86362001)(26005)(8676002)(83380400001)(53546011)(6506007)(4326008)(31696002)(66946007)(66476007)(66556008)(6512007)(6486002)(478600001)(44832011)(8936002)(2616005)(2906002)(36756003)(38100700002)(6916009)(5660300002)(41300700001)(316002)(38350700002)(31686004)(54906003)(186003)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a0JvdjNOSFdzUVd4bWZqbWw4ZXhWKytyd2x0OTlweUYxWi9lZzNMYUd2eGJI?= =?utf-8?B?REUvbzFBcG1LbUVjR25GMk95RkFERDNxMGwrZDlnN0Y5VFRxRjVvRHFNeHBK?= =?utf-8?B?bTd1NEhxRktsd3RUT3hiSE1YZlhWNGlEWStqc1FpVEZ3L2pkSXprLzNnZ2dR?= =?utf-8?B?aEFsL2ZPZGYxekRFVVdnYWRYUldLSTBXdm5YWFUxS0pXa0lTSmRlaUM0L2h2?= =?utf-8?B?L1ZTWjE5dFNhOVN4VmpGWmNmeFdNNjRYTEoydm5GS3daTW9LTHdSbk0vWmg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Z1JJa0NlVER4UW1JMEdNZlAzZXRG?= =?utf-8?B?aEpUQzZ6TlJURU52S2dJUHVyMmdKaWRQWHMvTDR1WjYrcDVHSVJ2eGgrdnBs?= =?utf-8?B?YkE9PQ==?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfbab786-0d52-4148-9a92-08da58e5938b X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4765.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2022 09:07:07.4220 (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: jlhhWTd58N9acU4onv/ty0njV0Hdjiy/Kb3PiCUz1UYCmu9ogL3WObEiNbgkGG2OJ6S6B0qPHBg7AymkVxJXbz2+fTfaow9hWAIVKkA7oNM/xLHboh/AuuZVmPXPocT0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1691 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 27/06/2022 23:42, Michael S. Tsirkin wrote: > On Mon, Jun 27, 2022 at 07:19:09PM +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. >> >> No pretty printing and fixed as per coding style. >> .... >> +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: %llx\n", "capabilities", b->vdev->features); > why do we need this in debugfs? Isn't this available in sysfs already? Yes, it doesn't make sense to have it without pretty printing. I will remove it. >> + seq_printf(f, "%-22s: %d\n", "page_size", 4096); > I suspect this function doesn't work properly when page size is not 4K. It is the page size used by the balloon and it is always 4K and not the page size used by the guest which can be different. /*  * Balloon device works in 4K page units.  So each page is pointed to by  * multiple balloon pages.  All memory counters in this driver are in balloon  * page units.  */ And the code agrees with the comment. To be consistent the file must use the same units. >> + >> + virtio_cread_le(b->vdev, struct virtio_balloon_config, actual, >> + &num_pages); >> + /* Memory returned to host or amount we can inflate if possible */ >> + seq_printf(f, "%-22s: %u\n", "ballooned_pages", num_pages); > I don't really get the comment here. I will try to reword it to be more clear .     /*      * 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.      */ >> + /* Total Memory for the guest from host */ >> + seq_printf(f, "%-22s: %lu\n", "total_pages", i.totalram); >> + >> + /* Current memory for the guest */ >> + seq_printf(f, "%-22s: %lu\n", "current_pages", i.totalram - num_pages); > Are you sure these are in units of 4Kbyte pages? The guest can have a different page size, so a conversion to balloon page size is required - fix in the following patch . -- Regards, Alexander Atanasov