Received: by 10.213.65.68 with SMTP id h4csp1683499imn; Thu, 15 Mar 2018 06:48:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELuftO0cZjA8Q/aWMqJ+XPYVRivzzne85A9tq/xYGl+2NExG6FJeAZGm2EXxCwmQSukaK4pt X-Received: by 10.99.114.77 with SMTP id c13mr6837350pgn.8.1521121699850; Thu, 15 Mar 2018 06:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521121699; cv=none; d=google.com; s=arc-20160816; b=eWin70HnEjToBRyYvjUMaeq2YDoiNN3Jd1EV9iIvKkZEH2eFLtl+gfhmAEPa2yjNJd LITTWlor7VoeNFHyTE/QKjrVsBwWNrrBc9g70gBFmv8JLxGXVCScZc3XKtKwB4zh142s E5SHVtrDpDUcKxdsGTBo52rz03NxrIfMrvwDRjSHv3sJlGce3Fq1GY5QUA4TtoCTePi4 qMg+Q1tHYTvRMQGK0lcbin7/JVUQ8bVl1dwMIioeuAzWkJesd6bgw8HMazVNvx6OeZpP ncc3dFuEep/l2ATizQa2PR/WAQOIUNzZzQck2Bber+Tjoknzv6vlGmMheHftcmj93hw7 l9VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=5W6sqdFk14AayYhkxzLTXIslM2el/1XYpc4TNJVNPlQ=; b=CKfvUiaUlx4YiW2WG0n2SnwKC0eGHqh3whWl0hiTGKXptp9Fbew1tvDVGXvw6mo2W+ L7iskD1f8QZk/hPPC9wc6SGoQMRoxO/ao3kUV1tIcoO+oIMLTIGqxFeLP/DOdByCWI0Z O8/gru4FrHFVNjoiXJUYmsEyWeoEOV06hZRzYcYn/apTvVINp6HJ5SlSJBc27A6kQICf 963r7qRoycvTU8tB+tUWF5SuX6ot5nYOmHaMeep1VRRtyB9R1rpFHKSsIzx2CgoJ/Efu EcTKWHSlYbBE0CvIloQrHSHF78PMXeazc9NeCbnHtzNx0y3CQGDLUgWJLqI9YOMNu63T o+vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n22si3491611pgc.121.2018.03.15.06.47.49; Thu, 15 Mar 2018 06:48:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752315AbeCONqM (ORCPT + 99 others); Thu, 15 Mar 2018 09:46:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751877AbeCONqL (ORCPT ); Thu, 15 Mar 2018 09:46:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB77640201A3; Thu, 15 Mar 2018 13:46:10 +0000 (UTC) Received: from redhat.com (ovpn-123-150.rdu2.redhat.com [10.10.123.150]) by smtp.corp.redhat.com (Postfix) with SMTP id 583ACC1234; Thu, 15 Mar 2018 13:46:07 +0000 (UTC) Date: Thu, 15 Mar 2018 15:46:06 +0200 From: "Michael S. Tsirkin" To: Greg KH Cc: Or Idgar , linux-kernel@vger.kernel.org, arnd@arndb.de, oidgar@redhat.com, ghammer@redhat.com, Or Idgar Subject: Re: [PATCH v5] drivers/misc: vm_gen_counter: initial driver implementation Message-ID: <20180315153311-mutt-send-email-mst@kernel.org> References: <20180301142215.11812-1-idgar@virtualoco.com> <20180313190617-mutt-send-email-mst@kernel.org> <20180314182536.GA14504@kroah.com> <20180314211704-mutt-send-email-mst@kernel.org> <20180315131959.GA28568@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180315131959.GA28568@kroah.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Mar 2018 13:46:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Mar 2018 13:46:10 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 02:19:59PM +0100, Greg KH wrote: > On Wed, Mar 14, 2018 at 09:25:17PM +0200, Michael S. Tsirkin wrote: > > On Wed, Mar 14, 2018 at 07:25:36PM +0100, Greg KH wrote: > > > On Tue, Mar 13, 2018 at 07:40:51PM +0200, Michael S. Tsirkin wrote: > > > > I think it's a good idea to use sysfs for this. However, > > > > there are a couple of missing interfaces here: > > > > > > > > 1. Userspace needs a way to know when this value changes. > > > > I see no change notifications here and that does not seem right. > > > > > > How can these change? > > > > It's a hardware register. It changes when hardware feels like it :) > > Does the hardware notify the kernel that it changes? Or does the kernel > have to "poll" for it? Yes - it sends an ACPI interrupt notification. > > In particular, it changes whenever VM is migrated or snapshotted. > > So very rarely. And userspace always knows about those events already, > right? Not at all. > > > > 2. Userspace needs to be able to read these without > > > > system calls. > > > > > > Ick, what? Why not? > > > > > > > Pls add mmap support to the raw format. > > > > > > For a single integer? Why do you need mmap for this? What is so > > > "performant" that needs to touch a sysfs file? > > > > (Phys address is not guaranteed to be page-aligned so you will > > > > probably want an offset attribute for that as well). > > > > > > Ick ick ick, that's why it's good to just stick with a sysfs file. > > > > > > Have you tested just how long this takes to see if the open/read/close > > > is really the bottleneck, or if the io on reading the value is the > > > bottleneck? > > > > > > thanks, > > > > > > greg k-h > > > > Well an application needs to check this value basically after > > every database transaction. > > "every"? That's horrid, why would you write a database that has to do > an ACPI i/o call for every transaction? That's a sure way to write a > very slow database :( Absolutely. That's why we might want to do an mmap and then get the ID from memory. An alternative is poll support so userspace can get notified about changes. Opens a bigger window during which you are doing duplicate work, but maybe that's not such a big issue. > > So I'm pretty sure it's a performance sensitive path. > > Given that this api is not present today, why is this even needed? Who > wants/needs it so badly that it has to be tuned in ways like this? > > If it is _really_ performant critical, just make it a new syscall :) Maybe you are right and it is a premature optimization. Let's put it out there without mmap support and see what happens - but then we definitely need poll support. > > But yes, I > > didn't profile any apps since they > > are yet to be written to use this interface. > > Then what database are you talking about? What apps need/want this > thing? > > thanks, > > greg k-h Anything that runs within a VM that is snapshoted is at risk of sending duplicate transactions when it's restored and time rolls back to a random point in the past. If you want the application to have ability to detect these, then VM gen ID offers a way to do it: id=read_id() do_work() new_id=read_id() if (new_id != id) find_and_handle_duplicate_work() -- MST