Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp258136pxb; Wed, 8 Sep 2021 00:00:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJzCHUzEuiCm7kcVVo5LQwQ22xznT6VyQaqtERtM380DMylH01zQ2dMsDSCPGWLuwFd6Gd X-Received: by 2002:a17:906:3fd7:: with SMTP id k23mr2460316ejj.176.1631084447953; Wed, 08 Sep 2021 00:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631084447; cv=none; d=google.com; s=arc-20160816; b=RUWBxjObyCWWOuk4fVx1n8vaYa0zFdP/KA5JBS/AM2DlgskGCZSALDb4uHZ2F6uqE8 XA1MLtb7ltNdjJbtZKuRKbh4+MZIGhyzkSSOTTi/MxG4+LIulN5OW/DFoch+y+/4iBqa 0HHt6f8kkRW9Aj1TF/7zHSDa7IOPsuqJOXegXjrrYijIzcv2nb1sktUc3nlk1F780yUe ++LNmkskdFkzGbAh5R2n0TyBPqinBnVMbMdaX//iKoFk63sinnab4os8r7/S0WIszf8R MdVbLy7hiBtq/VG1zmpG57mjjyEJzGcP5YywNgMrmNh3uScI0uuwPkP8R3QIi2cYP6BW Csfw== 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=yqhbwzwdJH8qRS1MarFWp8lRnwDdQKIjHrVncEEHPh8=; b=Vt5WqO3c7EqIFSykyopbo1mL1OwJPcT5dkIPIrO/CsyKjNusFT3kqumAVRkAAZQ3Vs Tt+BdKS1nvFpUcJLBUOFgHz3OCqqePugSaO2TNZ3kUHQ5+6QJV1Zluk/zA1TqOEkf2Iw sExWk26cJRMnyBR0HKc6recMNrHK6mT6yaJ2GwSlxyQ4/Fmhbtf2idQQ14SE28l4ijdF zoxqLCTXYwbd3pC5JQ5CFoIZELCZU2GndMEA5ekPFTRPFMGEtk2gAjemjBih6uyN/ZfH NDVctpzsinrL0fRnZIOqPJOSDn5YUXHasw3FKzrvj0ARb9KCsSNOEjIFpzJNASjd0TSX bV0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fgBDwHw7; 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 l4si1451363ejo.650.2021.09.08.00.00.22; Wed, 08 Sep 2021 00:00:47 -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=fgBDwHw7; 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 S1347844AbhIHG71 (ORCPT + 99 others); Wed, 8 Sep 2021 02:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343752AbhIHG7Z (ORCPT ); Wed, 8 Sep 2021 02:59:25 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B2AC061575 for ; Tue, 7 Sep 2021 23:58:18 -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=yqhbwzwdJH8qRS1MarFWp8lRnwDdQKIjHrVncEEHPh8=; b=fgBDwHw7l63tdQPsH7I2iUXyMZ u6GLvgy1FAu0zukPtZrZWZAGYTkNv93qLQ0SzlM4o/dSNEZZB34rJlFBTv+g/qg2PSEBxfH0qrtEq 40iF+eI7p8r9HBX4e+qdIj0FiX5kR8x0Cn7qtaYsW6Hvb2GMjQzPi+kaNS7GQYVkm5RdE447u5hGc 0550qzIoVi9MtzwZPjO8uku14gwMEt+yVYO9XZqzB0c2z092Fp/J7HiOH1tOmYfikBtfWZVXUaXy0 tBjOyYM79QvEb39a4jsRkH0T1KaIT2OpzIi4U5yUtMw5Yt8jo0gL7SIhFqjH9BrADxVv9XMb5RgYq euwSfHxg==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNrWF-008a9l-56; Wed, 08 Sep 2021 06:57:29 +0000 Date: Wed, 8 Sep 2021 07:57:15 +0100 From: Christoph Hellwig To: Jan Beulich Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , lkml , "xen-devel@lists.xenproject.org" Subject: Re: [PATCH 04/12] swiotlb-xen: ensure to issue well-formed XENMEM_exchange requests Message-ID: References: <588b3e6d-2682-160c-468e-44ca4867a570@suse.com> <397bf325-f81e-e104-6142-e8c9c4955475@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <397bf325-f81e-e104-6142-e8c9c4955475@suse.com> 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:32PM +0200, Jan Beulich wrote: > While the hypervisor hasn't been enforcing this, we would still better > avoid issuing requests with GFNs not aligned to the requested order. > > Signed-off-by: Jan Beulich > --- > I wonder how useful it is to include the alignment in the panic() > message. I further wonder how useful it is to wrap "bytes" in > PAGE_ALIGN(), when it is a multiple of a segment's size anyway (or at > least was supposed to be, prior to "swiotlb-xen: maintain slab count > properly"). > > --- a/drivers/xen/swiotlb-xen.c > +++ b/drivers/xen/swiotlb-xen.c > @@ -231,10 +231,10 @@ retry: > /* > * Get IO TLB memory from any location. > */ > - start = memblock_alloc(PAGE_ALIGN(bytes), PAGE_SIZE); > + start = memblock_alloc(PAGE_ALIGN(bytes), IO_TLB_SEGSIZE << IO_TLB_SHIFT); > if (!start) > - panic("%s: Failed to allocate %lu bytes align=0x%lx\n", > - __func__, PAGE_ALIGN(bytes), PAGE_SIZE); > + panic("%s: Failed to allocate %lu bytes align=%#x\n", > + __func__, PAGE_ALIGN(bytes), IO_TLB_SEGSIZE << IO_TLB_SHIFT); CAn you avoid the overly long lines here? A good way to make it more readable would be a variable to hold the byte count.