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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2038FC432BE for ; Fri, 27 Aug 2021 09:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0643660EAF for ; Fri, 27 Aug 2021 09:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232817AbhH0J0F (ORCPT ); Fri, 27 Aug 2021 05:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbhH0J0D (ORCPT ); Fri, 27 Aug 2021 05:26:03 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA70AC0613CF for ; Fri, 27 Aug 2021 02:25:14 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a25so12435443ejv.6 for ; Fri, 27 Aug 2021 02:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CQZSVnOjQTaOC4XZpSSeU/UltZMxftQtIHXd0FC9LUY=; b=Eiyqj+g5ZX6aj2srxpZtcC1FQBOndljXdzjzQhW3jQfg0AKnowg66sDkXhGEBa7ROp +53SIt2MmLtIoE8yXSbpYJx4I/VEj5rzSssq48dyRj2K9LTMGIxWpkX+rBd7bgLzzewm H7LTLql0SrRgfWYFJmh/kVwAwOxH4PN1xEh8cDnMjmoUUMNdlPpdKQKSpqobDjvAldfC cXn76T6Mu1zSuEcmMGjIeXjOf1VizyeMqiQ0WOFK5MjuDVZ5/RoACxnjGi7LF45nwgrQ Nfv9gXViN5n0dobPAoA9idt9BLeLe79P5wpff7nWT0kBWd8juzoAhi6J/RJ88ud8v62V 8eEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CQZSVnOjQTaOC4XZpSSeU/UltZMxftQtIHXd0FC9LUY=; b=pNcU9M4Kh293vFB2XtywXTdH0ac1s4aeLlTavNQv96nZQ7uC4gC3vpTpbkr9QPXEL/ KxZGa2YbWYahAj/6yWoeMd8xgutRsw2p5bX+Dewo2bNddIrguNfMJG2BGMmjCckfH0ZB 4JOD7gNsQ8ttLzk6slMToyjmpQjQ7g3yoKIQX7CG86Rd+fqBH/We8kZp/Q/AaGEJeb20 bnGZrcHnUBzCd2a5enSFi+g1+ltmjwQov9B1L811yiN7hf0vuH7p8iUzOnE72WMu8S79 3cZxa05SIcMO1FdY6O052ys1DI1dWfbnpwWl3Jtx44WY21XUX0Wuc/b+oduW093ChIwc OZ5g== X-Gm-Message-State: AOAM53294SFKgbIWyLUaJkpHBqWRSLWAYTk14RAnMWkTRRngt90xu7dK nzUJL6edL6FfA5laZp8Um7AkJX+yrD6PuZxOJp8E X-Google-Smtp-Source: ABdhPJwgcugxvkltcJohlXGHniUZmyhYLawWLaSxMYUiHXpZPra5boRHFyGEQTo7QNVw0MBfE++H/HV9ev3Dyf8sBpg= X-Received: by 2002:a17:906:659:: with SMTP id t25mr8879799ejb.372.1630056313220; Fri, 27 Aug 2021 02:25:13 -0700 (PDT) MIME-Version: 1.0 References: <20210818120642.165-1-xieyongji@bytedance.com> <20210818120642.165-11-xieyongji@bytedance.com> <2d807de3-e245-c2fb-ae5d-7cacbe35dfcb@huawei.com> In-Reply-To: <2d807de3-e245-c2fb-ae5d-7cacbe35dfcb@huawei.com> From: Yongji Xie Date: Fri, 27 Aug 2021 17:25:02 +0800 Message-ID: Subject: Re: [PATCH v11 10/12] vduse: Implement an MMU-based software IOTLB To: John Garry Cc: "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Stefano Garzarella , Parav Pandit , Christoph Hellwig , Christian Brauner , Randy Dunlap , Matthew Wilcox , Al Viro , Jens Axboe , bcrl@kvack.org, Jonathan Corbet , =?UTF-8?Q?Mika_Penttil=C3=A4?= , Dan Carpenter , joro@8bytes.org, Greg KH , He Zhe , Liu Xiaodong , Joe Perches , Robin Murphy , kvm , netdev@vger.kernel.org, linux-kernel , virtualization , iommu@lists.linux-foundation.org, songmuchun@bytedance.com, linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 27, 2021 at 4:53 PM John Garry wrote: > > On 18/08/2021 13:06, Xie Yongji wrote: > > + > > +static dma_addr_t > > +vduse_domain_alloc_iova(struct iova_domain *iovad, > > + unsigned long size, unsigned long limit) > > +{ > > + unsigned long shift = iova_shift(iovad); > > + unsigned long iova_len = iova_align(iovad, size) >> shift; > > + unsigned long iova_pfn; > > + > > + /* > > + * Freeing non-power-of-two-sized allocations back into the IOVA caches > > + * will come back to bite us badly, so we have to waste a bit of space > > + * rounding up anything cacheable to make sure that can't happen. The > > + * order of the unadjusted size will still match upon freeing. > > + */ > > + if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1))) > > + iova_len = roundup_pow_of_two(iova_len); > > Whether it's proper to use this "fast" API or not here, this seems to be > copied verbatim from dma-iommu.c, which tells me that something should > be factored out. > Agreed. > Indeed, this rounding up seems a requirement of the rcache, so not sure > why this is not done there. > Me too. I guess it is to let users know that space is wasted. Thanks, Yongji