From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13A89C00140 for ; Wed, 10 Aug 2022 06:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbiHJGF3 (ORCPT ); Wed, 10 Aug 2022 02:05:29 -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-Google-Smtp-Source: AA6agR4zsECaQisdchCePlp4yUAvq88BKlsK7g/FdrfvnijgIa0+CeZxy11peJJUHhW3QeKUTE6NCQ== 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: 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