Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1677822imc; Mon, 11 Mar 2019 20:53:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3ekL6SwoqBYq/GqsaSR+ZvL3O8rVA1q6McVAuCR/RTp87+3P9Ix7HUrDQK6NS4cVUviZB X-Received: by 2002:a62:1303:: with SMTP id b3mr37733277pfj.147.1552362836738; Mon, 11 Mar 2019 20:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552362836; cv=none; d=google.com; s=arc-20160816; b=V4ROK3MUpmFq6ahZVHbb4waLlzQrsUSENRpqV+Uabingiwf+wls4f+9Xk1ELO4xVg7 T2ZaCxnenYAWm5cOQi753uM011aQROnH3qkgQ6ZvOSqmy/AJ92wBm9cF2GCxPl+Ivxag ci2fbzUDS0T1B91M/zzstbXIZKevVbVvQeRsb14XuXjTDrOGAvZHLFedimkqW8KJA/ND DFYT7U+P5AWRresfxCQUdqKVU5BDy6rk/XWPr+OV/k4w2E+siuZl3cObIis/8OO9BB3l vezwMxSxrRFLEaK90qqbcI4oaVoZMUZqGzYNSb2WaFHT+Og9qKzm6eyzgCEH1bSyFk1L aljA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=q5OtFmBn4kunq3TRH7QETyZ6fOkGOBD8DRouuexq1Q0=; b=NolgjElduRkN5dzpjAAyH9QHJ3y/1/hode1lxDHts+mnkB/qjS6SO8dAm7KVn+Qs+t jrZoH0yqR6WdRlx8LffR0qi6vt9WTm+6JBnT7L3TpiKBFOgexq+ndxxw7GzBkLCiSWbe vkhVwAYxKUArUjn8bLcxHIL8L53mEZ47FZSkCqZzJhVyw/O79Hb8s8VYXGZ5sfpFgocs vZbu0HbKsTyA4m0VdH5fMbUFpR/daWNwomtCcnpV5saZRoICWuQY4d60KfSfR9IB5wyj QV2t/Ybnc5grvGg/wCvTLAxe6xhZzpaL3EvAwXv8etoRK2gzBxHZU0hUAMgaXjosXYC8 voew== 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 h12si6566886pgl.277.2019.03.11.20.53.41; Mon, 11 Mar 2019 20:53:56 -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 S1726995AbfCLDva (ORCPT + 99 others); Mon, 11 Mar 2019 23:51:30 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:34387 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726922AbfCLDv3 (ORCPT ); Mon, 11 Mar 2019 23:51:29 -0400 Received: by mail-qt1-f193.google.com with SMTP id x20so1124807qto.1 for ; Mon, 11 Mar 2019 20:51:28 -0700 (PDT) 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:content-transfer-encoding :in-reply-to; bh=q5OtFmBn4kunq3TRH7QETyZ6fOkGOBD8DRouuexq1Q0=; b=DlXKBYDN4M+yxGxoxlbUQDEzy2HCI27SsF6HHQ6LYMbM5ek0CjD97YMpME2qyPVPz4 SebGR12DAD2adfpSowLrR4Ur8Pf/0hCgD5TguH1ThXqOfq0kpDNYheDr5TVyI4sLe6gF GX6EJIM36KpbzZhwhYeNU/nx/P3fuGo6jaiESTT92C2Sf+mJdlDJwJ3PaxvB9qjyZxFa 3EZ1Ug/9J046bS6TBIUv6gpt6ACeYvoEhWfEIZ9jMVHs1P5dMjIR03pPvCPodH4bICHn oHbdLeKt6wCb/9XJelUptdRjKw/lIz7oSXCnVnGp2on8zlOU6ZBNOGHoWgiXzH6C0jWI HkIw== X-Gm-Message-State: APjAAAXO6RG+VZ3ZjTegcC+vomzMm8GseY99K0ScbgRPLmEEu0a6Yher g08wZNFSJ+RO51ZsPd1g87Htcg== X-Received: by 2002:aed:3f81:: with SMTP id s1mr26463323qth.94.1552362688407; Mon, 11 Mar 2019 20:51:28 -0700 (PDT) Received: from redhat.com (pool-173-76-246-42.bstnma.fios.verizon.net. [173.76.246.42]) by smtp.gmail.com with ESMTPSA id j139sm4250733qke.26.2019.03.11.20.51.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 20:51:27 -0700 (PDT) Date: Mon, 11 Mar 2019 23:51:25 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: Andrea Arcangeli , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, peterx@redhat.com, linux-mm@kvack.org, Jerome Glisse Subject: Re: [RFC PATCH V2 5/5] vhost: access vq metadata through kernel virtual address Message-ID: <20190311235100-mutt-send-email-mst@kernel.org> References: <1551856692-3384-6-git-send-email-jasowang@redhat.com> <20190307103503-mutt-send-email-mst@kernel.org> <20190307124700-mutt-send-email-mst@kernel.org> <20190307191622.GP23850@redhat.com> <20190308194845.GC26923@redhat.com> <8b68a2a0-907a-15f5-a07f-fc5b53d7ea19@redhat.com> <20190311084525-mutt-send-email-mst@kernel.org> <20190311134305.GC23321@redhat.com> <4979eed5-9e3f-5ee0-f4f4-1a5e2a839b21@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4979eed5-9e3f-5ee0-f4f4-1a5e2a839b21@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 12, 2019 at 10:56:20AM +0800, Jason Wang wrote: > > On 2019/3/11 下午9:43, Andrea Arcangeli wrote: > > On Mon, Mar 11, 2019 at 08:48:37AM -0400, Michael S. Tsirkin wrote: > > > Using copyXuser is better I guess. > > It certainly would be faster there, but I don't think it's needed if > > that would be the only use case left that justifies supporting two > > different models. On small 32bit systems with little RAM kmap won't > > perform measurably different on 32bit or 64bit systems. If the 32bit > > host has a lot of ram it all gets slow anyway at accessing RAM above > > the direct mapping, if compared to 64bit host kernels, it's not just > > an issue for vhost + mmu notifier + kmap and the best way to optimize > > things is to run 64bit host kernels. > > > > Like Christoph pointed out, the main use case for retaining the > > copy-user model would be CPUs with virtually indexed not physically > > tagged data caches (they'll still suffer from the spectre-v1 fix, > > although I exclude they have to suffer the SMAP > > slowdown/feature). Those may require some additional flushing than the > > current copy-user model requires. > > > > As a rule of thumb any arch where copy_user_page doesn't define as > > copy_page will require some additional cache flushing after the > > kmap. Supposedly with vmap, the vmap layer should have taken care of > > that (I didn't verify that yet). > > > vmap_page_range()/free_unmap_vmap_area() will call > fluch_cache_vmap()/flush_cache_vunmap(). So vmap layer should be ok. > > Thanks You only unmap from mmu notifier though. You don't do it after any access. > > > > > There are some accessories like copy_to_user_page() > > copy_from_user_page() that could work and obviously defines to raw > > memcpy on x86 (the main cons is they don't provide word granular > > access) and at least on sparc they're tailored to ptrace assumptions > > so then we'd need to evaluate what happens if this is used outside of > > ptrace context. kmap has been used generally either to access whole > > pages (i.e. copy_user_page), so ptrace may actually be the only use > > case with subpage granularity access. > > > > #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ > > do { \ > > flush_cache_page(vma, vaddr, page_to_pfn(page)); \ > > memcpy(dst, src, len); \ > > flush_ptrace_access(vma, page, vaddr, src, len, 0); \ > > } while (0) > > > > So I wouldn't rule out the need for a dual model, until we solve how > > to run this stable on non-x86 arches with not physically tagged > > caches. > > > > Thanks, > > Andrea