Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6738637rwb; Tue, 9 Aug 2022 23:34:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5gpKvClJTFhCpIdy6AuRoUXMhXCUFlg9WzCVKbWVZTRmZedH6YCGcXc6tMzJd44fKRqTEp X-Received: by 2002:a05:6a00:842:b0:52e:2515:d657 with SMTP id q2-20020a056a00084200b0052e2515d657mr25672245pfk.31.1660113261467; Tue, 09 Aug 2022 23:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660113261; cv=none; d=google.com; s=arc-20160816; b=fmalcqHD1tfqV7WencWuO1J5aCLuUJoTj6iRgoDKRWyQ8IMSvoYvnZzPCCGGPeoYbM BmKuVHJ05M3IXr1U9Fwgb2NGq/1yashDshXuCDuUhy7WqqcoP/d6rA3NBwlQLhnejwIg kPDXcBnwsZ767BWdj9iiOOOyQSU0z0spvaDRwAs80zs7mSYfdvXl+hEZWoEmqZKCVF4G uPNVhGDWM+/O2UGM7VkK02n0R/qr4CcGUxJrYlBhg08ww6iuBwpZiznfSYnB0Ak0er4L VgxG7qu2nmpYh6UrPqzo/UH/aNHv+BP8j3m1wnCLE4DRU6q2HkUUO2s3SGpFp4Hgu4NK 8MXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sBlUQH9ZYI87QjLCL8xa8WoZuHTUiJ4rE7hGqowqg5w=; b=TnMKV2H3+bRxYIIJ6qfkomk2RYlo541QUj1d0VukiFNzBrZoyC+znJo1OOWxNKafII JVGXNeTzKGK+XC4qOPmnARVCTKwdRPYSg2rMnSlH0tqOyJj1WlhY6HjS4H01iMymovEG P6AVEhfPwh2zkJuD7FNAiVj27Q2rqIoFh7/GwEbP/b77//IN56dv4stivzvfvSVQB5mi JLgiFtCeMPF7619wvltQE8b6hRNdmMpJ957ZseiroQQ8gTmr8LSsdbofccSM7mP9LcaG 8snknYr9qPGB9ruo/Hlf5aQULXLqbGpoiz55Eq6AelVUI4fw27SF3I6kQHVr4Oz0Od8z 6Epw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dmh6Ql3p; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj9-20020a17090b3e8900b001f500ecbad8si1232061pjb.161.2022.08.09.23.34.04; Tue, 09 Aug 2022 23:34:21 -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=@redhat.com header.s=mimecast20190719 header.b=dmh6Ql3p; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231228AbiHJGF2 (ORCPT + 99 others); Wed, 10 Aug 2022 02:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbiHJGF0 (ORCPT ); Wed, 10 Aug 2022 02:05:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA06326569 for ; Tue, 9 Aug 2022 23:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660111525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sBlUQH9ZYI87QjLCL8xa8WoZuHTUiJ4rE7hGqowqg5w=; b=dmh6Ql3pwrvd7E5wpD+DPyx2jgF4pAK+y5QOsuAH2TWEeQh9732acHsvdU1WxD7yFb+2Ks MSSiNNHthIs8qgKqhPVkaON/eAf7U3/s8lJsHvoOl+QKkNHHoOVoP5USxetBqa/vAiIv+Z 2hlYec2yNJGywAjQhi2ZZLxn6QjWekI= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-g6CnshDEMjylHrBsH_1XNQ-1; Wed, 10 Aug 2022 02:05:15 -0400 X-MC-Unique: g6CnshDEMjylHrBsH_1XNQ-1 Received: by mail-ed1-f72.google.com with SMTP id t13-20020a056402524d00b0043db1fbefdeso8556279edd.2 for ; Tue, 09 Aug 2022 23:05:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=sBlUQH9ZYI87QjLCL8xa8WoZuHTUiJ4rE7hGqowqg5w=; b=efiBCqFXvvXz/ed0hShS/wt20+H+DSJCyBD28yT206ORXCeQC1KebiLkxBdvmYmHqX sL+oMEvwqiS//mYyfz3VMpc+dDaZuhjkAlcDrVvAoKzh0yjV9MznaDFjGXHmH7QSxnHp vENwWMkgGDq8kFfhUWs9Aa3He0SuQO8PcZcrqj1R8sDxmOi23KkyDuddK68x/Dfqzn7x YriZvsJiLuEcA6DW5rmg9s5Em93oELF1FFJ1qugygSBrY3LRDKZPFdzn7MhubYSbxU3S bVd1m115CRim1lZhXwErLcEjcOM8/DG2mKxKz1Wdb5uzSQa1a23RGi+sp0R6zmAgLpqY BC7Q== X-Gm-Message-State: ACgBeo3xlAtxqo8ya8HqRbrucP8nswYmq6E/XZAudO43eJVZ9rL3cT80 WTuwoMn68R9xhECkuJHrDhQrDfBsQhJ/smMHEDiw8K4E6hIFk0r9EyTKngiiNtalEXgxMwS/CNr wgJV7MwYon0NhUYQUY4wgh7dn X-Received: by 2002:a17:906:fd84:b0:730:acee:d067 with SMTP id xa4-20020a170906fd8400b00730aceed067mr19393956ejb.206.1660111514487; Tue, 09 Aug 2022 23:05:14 -0700 (PDT) X-Received: by 2002:a17:906:fd84:b0:730:acee:d067 with SMTP id xa4-20020a170906fd8400b00730aceed067mr19393941ejb.206.1660111514262; Tue, 09 Aug 2022 23:05:14 -0700 (PDT) Received: from redhat.com ([2.52.152.113]) by smtp.gmail.com with ESMTPSA id b18-20020a17090630d200b00732a5b3d09csm1658020ejb.89.2022.08.09.23.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 23:05:13 -0700 (PDT) Date: Wed, 10 Aug 2022 02:05:09 -0400 From: "Michael S. Tsirkin" To: Alexander Atanasov Cc: Jonathan Corbet , Andrew Morton , kernel@openvz.org, David Hildenbrand , Wei Liu , Nadav Amit , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 1/2] Enable balloon drivers to report inflated memory Message-ID: <20220810020330-mutt-send-email-mst@kernel.org> References: <7bfac48d-2e50-641b-6523-662ea4df0240@virtuozzo.com> <20220809094933.2203087-1-alexander.atanasov@virtuozzo.com> <20220809063111-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Wed, Aug 10, 2022 at 08:54:52AM +0300, Alexander Atanasov wrote: > On 9.08.22 13:32, Michael S. Tsirkin wrote: > > On Tue, Aug 09, 2022 at 12:49:32PM +0300, Alexander Atanasov wrote: > > > @@ -153,6 +156,14 @@ static int meminfo_proc_show(struct seq_file *m, void *v) > > > global_zone_page_state(NR_FREE_CMA_PAGES)); > > > #endif > > > +#ifdef CONFIG_MEMORY_BALLOON > > > + inflated_kb = atomic_long_read(&mem_balloon_inflated_kb); > > > + if (inflated_kb >= 0) > > > + seq_printf(m, "Inflated(total): %8ld kB\n", inflated_kb); > > > + else > > > + seq_printf(m, "Inflated(free): %8ld kB\n", -inflated_kb); > > > +#endif > > > + > > > hugetlb_report_meminfo(m); > > > arch_report_meminfo(m); > > > > > > This seems too baroque for my taste. > > Why not just have two counters for the two pruposes? > > I agree it is not good but it reflects the current situation. > Dirvers account in only one way - either used or total - which i don't like. > So to save space and to avoid the possibility that some driver starts to use > both at the same time. I suggest to be only one value. I don't see what would be wrong if some driver used both at some point. > > > And is there any value in having this atomic? > > We want a consistent value but just READ_ONCE seems sufficient ... > > I do not see this as only a value that is going to be displayed. > I tried to be defensive here and to avoid premature optimization. > One possible scenario is OOM killer(using the value) vs balloon deflate on > oom will need it. But any other user of that value will likely need it > atomic too. Drivers use spin_locks for calculations they might find a way to > reduce the spin lock usage and use the atomic. > While making it a long could only bring bugs without benefits. > It is not on a fast path too so i prefer to be safe. Well we do not normally spread atomics around just because we can, it does not magically make the code safe. If this needs atomics we need to document why. > -- > Regards, > Alexander Atanasov