Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp285184pxb; Wed, 8 Sep 2021 00:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf64WmrtFI4PBI72+2q9QqtrGGPrasRr2IKty5WAhwgXPzJzVHhaly4/YcTsRQc+yKmsNr X-Received: by 2002:a17:906:4994:: with SMTP id p20mr2736804eju.38.1631087331079; Wed, 08 Sep 2021 00:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631087331; cv=none; d=google.com; s=arc-20160816; b=cgtpPH8XtqdknjfNfvn7ePr11RXnXC39YPm4F0veXzt94tGh1n2tHzaEAucdQKu5fx Ec0ulZB/c+CPE829BTnSYdKJTbKa4OxkRvk7mhiqytBZzNg0WvgKUOPTGs+Z7BJZu8XJ Prj1Srm9AdMMK3mNNulL6ik8QU7tAuGjaUAPosnn6lRJ/zrdJ18oQFzxIJoXRpC1o9a1 00q/G9d+dDyX6teavROpPJ4qWxlbRMs44Yy6757RuycXDlDKnMwXLLvyfL5wX7TMEDjC 3O9eJIMHn8UeCNMIhIwKypRwDi8BNKcoUhB/G8MiLJZn0Rm2wp7OeuNOIc3+2ddJa01T +iEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mNv6jBhL0dwmk4rDDYf4ikhCU0kC8phJg4t0M4uQRDc=; b=nmHPX8fDf7ZIpuwQZqEENEcvzt2gWYwLytdoV7iY0SfKd8lABqxmLEnt8CAyXkB68R +6aXh3w2UeGkISKIl2Ngq8JjeO09D19439sTKHoMEz/zHvS+XNH3Y9K4sC04twTwJd1X KzDI3wd9ODrWEKSfgZ7/zj0jztWXu8rJTt6L/gV3kxXNuNloq0De+OqHlQbVwT/zzJz9 tscZXweUcqUxVxiBO8NNNgvLBMJf13W0UlN1H5Smmuc7yEEIRGkvkzGl+ExEzFxVkE/E qFaiDHYlcIF/r7m8S0C9i0F1ZzyslrwJVKoz/e66x865TQYinkwTRUSLnH1Pkook+I8E KxNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aE5y0hGl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k13si1414215ejp.411.2021.09.08.00.48.27; Wed, 08 Sep 2021 00:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aE5y0hGl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347806AbhIHGz4 (ORCPT + 99 others); Wed, 8 Sep 2021 02:55:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244241AbhIHGzz (ORCPT ); Wed, 8 Sep 2021 02:55:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1056C061575 for ; Tue, 7 Sep 2021 23:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mNv6jBhL0dwmk4rDDYf4ikhCU0kC8phJg4t0M4uQRDc=; b=aE5y0hGlp2Xj4xb952dvEVdScM KnAkeo8HeySFYAkHcdp37IMVTE1i0gtREK8+yHbyQ5UCZahHa1/ncIMqtviCOSYTzL/AmK9KAmrfa GbkJD7rJALGnUYk7MMG+5GPjSi3u2vcTySZWbKcHBhIaTZfX4KhIV1b8fYvgn6mid2qUVy57Zv+xj bT3JLbdCLI2NEQBhgA864/cN0ICBGxedybXpxHkTrhaXYJUYyO3bprAOlD7SGZz90vpWEEFcJpiki keuEbK6oYViBMYnqTQotJTIhoHqzVhJ17AvLP/tLzLc46VGBhDiVNvg6j04I7IECrcc9WRWQ0W5gg EL39LFfg==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNrSS-008a0O-5n; Wed, 08 Sep 2021 06:53:45 +0000 Date: Wed, 8 Sep 2021 07:53:20 +0100 From: Christoph Hellwig To: Jan Beulich Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , lkml , "xen-devel@lists.xenproject.org" Subject: Re: [PATCH 03/12] swiotlb-xen: maintain slab count properly Message-ID: References: <588b3e6d-2682-160c-468e-44ca4867a570@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 07, 2021 at 02:05:12PM +0200, Jan Beulich wrote: > Generic swiotlb code makes sure to keep the slab count a multiple of the > number of slabs per segment. Yet even without checking whether any such > assumption is made elsewhere, it is easy to see that xen_swiotlb_fixup() > might alter unrelated memory when calling xen_create_contiguous_region() > for the last segment, when that's not a full one - the function acts on > full order-N regions, not individual pages. > > Align the slab count suitably when halving it for a retry. Add a build > time check and a runtime one. Replace the no longer useful local > variable "slabs" by an "order" one calculated just once, outside of the > loop. Re-use "order" for calculating "dma_bits", and change the type of > the latter as well as the one of "i" while touching this anyway. > > Signed-off-by: Jan Beulich Looks good, Reviewed-by: Christoph Hellwig