Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1168638ybl; Wed, 18 Dec 2019 14:00:06 -0800 (PST) X-Google-Smtp-Source: APXvYqydJdSlU7Y+7N2Z11afnJ7LuC6XatxP7NGmlGCvfQj8MFpycLA0d33LUsxfsNTTPNhWE4n1 X-Received: by 2002:a9d:6f0a:: with SMTP id n10mr5200194otq.54.1576706406147; Wed, 18 Dec 2019 14:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576706406; cv=none; d=google.com; s=arc-20160816; b=JjgrHqwv2/l2o2gAJzlahiZJ4w1AUKgHvFEYsqSnR4/deg51k9lCLx8T7htcnk8t8u NzR0sc/jHalzToMR2a4kUzCNGDt3PfG7pmW2TzHb1R7zlahDdrLGja+57QEto9B71s5H bYEIsQU8Ur76mlfVJ7UPXBh+Htf8C4jDdmRgHbl1MWFEEeymUs0vkxa0ph6fYJjyLPiN /n7mr527Djn44+4q8U3C2tKyrPddMG3TIhWxb6g+7q1chS/KtlnJCwyDKSrrymBx6E+W fEP8UfP12DB5ui0GqHam8szJfBJREOeHTEfx366h3tGDzAL1ISlemXnismWh5jUrGlk1 3EJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xyRq0uSWZtoF1xSeEB8lICjPIcYYqv0mpEMiHQwYmsc=; b=dECZ2QaUOh+3PNXzvFReQJwgtkdaWp9E0AQPgyfQLtz4KeomhxqTBF8wn7ykEdXDUW vTXRvF9gzhFqblm1CrIYxQ97jhw4Y2KxlEDz0/U4KyI2BiFEYTv2kbgqU+uKwfT+ORos aPOODNNQgrnkibv9NQNk+TyXy7jw10tFJLSxzY5lcbV8Z3kcubXIAubQuAdg0Z7WA14G Z9wV8QQN1JHvcGcklgIVJ5jt1JbMZc8fEf8vimIQ3mBAA6NkimOq91mGp6mgaIalW8gy SuN4kDQhXG2NEYfSYobz3o2HJIUlMEWdsGBQp9hCvlitFKapJ3zfTqawTI7eICN5T9pS 4tXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZobevB9e; 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=pass (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 l128si2171687oih.108.2019.12.18.13.59.54; Wed, 18 Dec 2019 14:00:06 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZobevB9e; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727443AbfLRV7J (ORCPT + 99 others); Wed, 18 Dec 2019 16:59:09 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29389 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727505AbfLRV7E (ORCPT ); Wed, 18 Dec 2019 16:59:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576706343; 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=xyRq0uSWZtoF1xSeEB8lICjPIcYYqv0mpEMiHQwYmsc=; b=ZobevB9evxz2RgIMe+dHIFnQWUUaXf9xhegU6owLqq3OdoVW8c4u7i36HIckZwYMGu3kj3 aYE4x8QrTir48rqJIPhFhEIbwnKvAqnycAtvqnDMi2teXwYvw5P2Rkn30ZcD3/gxjCHhZf +eNCpTUn5fQD/QdVRSHHGa8LUob4kq0= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-280-AI67nVF-N920XRFMH7kMRA-1; Wed, 18 Dec 2019 16:59:00 -0500 X-MC-Unique: AI67nVF-N920XRFMH7kMRA-1 Received: by mail-qv1-f70.google.com with SMTP id d7so2298923qvq.12 for ; Wed, 18 Dec 2019 13:59:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xyRq0uSWZtoF1xSeEB8lICjPIcYYqv0mpEMiHQwYmsc=; b=T8tQofdGnKlTEn4eoYXNwGNzZDkuny7/edml+4nz5EbpyANj69DKUKAU0nH9E3/d+1 kEuB5L0gfPhpzApa/gGwWS+gGGzu5O6zyzmNMjzlEusmd20Ogaa3WWH49TXtlPAlaGou SCrGEmVK4rgW4C3Q8rJBrBiJUykGogFWvnU3n0NNTNOKOs90n8M4kJ03WFAScLFdb5Z9 MeF38NganVmE5vRQpdhmN1ANZQrYUgkVfdnoTBaFGKdJ4sTAx7Q7N2F5D/UgXj4zRovG HsJPtSrJ3L6+qEpwGI9LljlA2qj/cMgT26DsMwu2vq3a076nHWiCPGxpso3+AsCZZ0/k 2eWQ== X-Gm-Message-State: APjAAAUpfVPD9+sDGypf8rxWicC3PzeYrf/UB8QF6acbLMuIOCOaWjjN aEMiAAgp2UUZKxovMfA48vEGNpX/WwEjj+J1L5jh++eL3oo565RvuKJu+OfIX9W5XP0Odcf/obu RhY9EkcLLT7LMSpZsgJtfZHK1 X-Received: by 2002:a37:4905:: with SMTP id w5mr4969504qka.267.1576706340079; Wed, 18 Dec 2019 13:59:00 -0800 (PST) X-Received: by 2002:a37:4905:: with SMTP id w5mr4969484qka.267.1576706339769; Wed, 18 Dec 2019 13:58:59 -0800 (PST) Received: from xz-x1 ([104.156.64.74]) by smtp.gmail.com with ESMTPSA id e2sm1066715qkb.112.2019.12.18.13.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2019 13:58:58 -0800 (PST) Date: Wed, 18 Dec 2019 16:58:57 -0500 From: Peter Xu To: Paolo Bonzini Cc: Sean Christopherson , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "Dr . David Alan Gilbert" , Vitaly Kuznetsov , Alex Williamson , "Tian, Kevin" Subject: Re: [PATCH RFC 04/15] KVM: Implement ring-based dirty memory tracking Message-ID: <20191218215857.GE26669@xz-x1> References: <20191209215400.GA3352@xz-x1> <20191210155259.GD3352@xz-x1> <3e6cb5ec-66c0-00ab-b75e-ad2beb1d216d@redhat.com> <20191215172124.GA83861@xz-x1> <20191216185454.GG83861@xz-x1> <815923d9-2d48-2915-4acb-97eb90996403@redhat.com> <20191217162405.GD7258@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 17, 2019 at 05:28:54PM +0100, Paolo Bonzini wrote: > On 17/12/19 17:24, Peter Xu wrote: > >> No, please pass it all the way down to the [&] functions but not to > >> kvm_write_guest_page. Those should keep using vcpu->kvm. > > Actually I even wanted to refactor these helpers. I mean, we have two > > sets of helpers now, kvm_[vcpu]_{read|write}*(), so one set is per-vm, > > the other set is per-vcpu. IIUC the only difference of these two are > > whether we should consider ((vcpu)->arch.hflags & HF_SMM_MASK) or we > > just write to address space zero always. > > Right. > > > Could we unify them into a > > single set of helper (I'll just drop the *_vcpu_* helpers because it's > > longer when write) but we always pass in vcpu* as the first parameter? > > Then we add another parameter "vcpu_smm" to show whether we want to > > consider the HF_SMM_MASK flag. > > You'd have to check through all KVM implementations whether you always > have the vCPU. Also non-x86 doesn't have address spaces, and by the > time you add ", true" or ", false" it's longer than the "_vcpu_" you > have removed. So, not a good idea in my opinion. :D Well, now I've changed my mind. :) (considering that we still have many places that will not have vcpu*...) I can simply add that "vcpu_smm" parameter to kvm_vcpu_write_*() without removing the kvm_write_*() helpers. Then I'll be able to convert most of the kvm_write_*() (or its family) callers to kvm_vcpu_write*(..., vcpu_smm=false) calls where proper. Would that be good? -- Peter Xu