Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp212574lqt; Mon, 18 Mar 2024 06:05:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQkTDRCb8HeBgXoX7MP4I1cwT+UEJ+W1uMtV2Uq/4YBYgOLpzrPyx0YDr56iW2RvorCVU9+VPmIf9TW60tvIv1HOtopwdP+eqbi85EEg== X-Google-Smtp-Source: AGHT+IEPa3HY/ECbnaZwjQt+G6mtPJ6zoVoF1I1eLubhnsZpBYVGFhAlxPcWbFDf+aftbz8VjCN1 X-Received: by 2002:a05:6602:4907:b0:7cb:f725:f4c2 with SMTP id ef7-20020a056602490700b007cbf725f4c2mr9471896iob.21.1710767148244; Mon, 18 Mar 2024 06:05:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710767148; cv=pass; d=google.com; s=arc-20160816; b=ppzdvXsAt8czSCWi6Et6cvBhIXsG9TfthuW1FcUAZl+uifTIGE+IvaTRWEDwrYSNJ9 ySX4HK6auWLlCFbZKtOQfz1TSzUJDzrOlrrnZhRuGdOtIjAlEcf219q/sHzNPb6SG9T8 v/ixkpnP21+HBkmLZmuLnIUlB/7kFL3kw33iqaQb9ultFON28aYvPlf57Et/hb43ojyX l22tHsYEXXa6R1X9fh0ah2Bri2+yowZMmDGL0pUINcM7aFiNCiFJyl9I7VUo1ntb8/04 yyCPhAdMcaDqR+Y6Y2ZrgNMWgpG/KI78Jpi6RiBwCWUUHWtwFQ6rG9AXWVvYHLuWU+1a xKRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=IGw2cuyHKX/JAXFfSGqqPjTJXQRweJhxJ/lpYfVnLh0=; fh=TUtqPNITlAPcyXWS7RAUk8qxyVyWeYv4r4Stj6lpk0s=; b=IJyyks+d9feXoewd5KzUJmNIpIj6Qh0kY/JN3cBp0VKuft1iPelj+PiCX3t2Mr9gDJ T1r26MqxmgEsXUNtnfO/5lIAPAkuvuL44yq5uH3xNsrAER4RTckjLBIwQUVZizCWWYDZ IAaQdT4VBwrehB/6AYh+2Qt4wMtuPPNEeiItJ74UMSDvACl3+eZ3/+GG92D3EpnpcZHK PFCtf6/uZ1kBCaGS6ICTuGkEH/UsmG56DqH/ru17Ix3PmwvJSjyoDrPUDSV/EyNW5Sl+ jwbNwf/MugDF8veLFtKwd+h9MFFTuHVHdnxCOJrocxNNaoqyfuNPDcrXMr5JJFUah78p rVHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-106142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106142-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id by4-20020a0566023a0400b007cc051f572asi1960073iob.98.2024.03.18.06.05.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 06:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-106142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106142-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E557E282329 for ; Mon, 18 Mar 2024 13:05:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C8BE3FBA2; Mon, 18 Mar 2024 13:05:09 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A605B3FB99 for ; Mon, 18 Mar 2024 13:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710767109; cv=none; b=qsK5lkeIbxd7wAOlpNWlbQSWF8IoK2lfF/+GZoUcMk5OWMeUOvmiiRYuLjvpRe3aSskT/H8qcmGg1zfoSI+6p1I+XKQ0Ext1YcrTwhCnHjJUXh+shmao1OvV9Hz4ivfweYTIGkmQ6q0nKyzfHPYTl+m+upcuOeZ0irZeTulQZuY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710767109; c=relaxed/simple; bh=ZarPO9ClVSp9miIoAdrkxdLyf33d8aB50kRIYFkoTQw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tjT5YHY9l38Z7cttFSNMfn3XV/dMIpee8wqrSINhOIykgrwW0GcQk3tWZU0bTQHG5vH266TwdT2dgEiQSsPD8/qy2NunTi6yLpx//E8JzFSSurgS9HiUDlarDjbxn8jEWs2x1L4ig43NZfhr5CCbURqk/5N1r594Us8pg+H2Cqs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DCE18DA7; Mon, 18 Mar 2024 06:05:40 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 87B973F23F; Mon, 18 Mar 2024 06:05:04 -0700 (PDT) Message-ID: Date: Mon, 18 Mar 2024 13:05:03 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] swiotlb: extend buffer pre-padding to alloc_align_mask if necessary Content-Language: en-GB To: Michael Kelley , Petr Tesarik , Christoph Hellwig , Marek Szyprowski , Will Deacon , Nicolin Chen , "open list:DMA MAPPING HELPERS" , open list Cc: Roberto Sassu , Petr Tesarik References: <20240312134149.497-1-petrtesarik@huaweicloud.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 15/03/2024 2:53 am, Michael Kelley wrote: [...] >> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c >> index 86fe172b5958..8ce11abc691f 100644 >> --- a/kernel/dma/swiotlb.c >> +++ b/kernel/dma/swiotlb.c >> @@ -69,11 +69,13 @@ >> * @alloc_size: Size of the allocated buffer. >> * @list: The free list describing the number of free entries available >> * from each index. >> + * @padding: Number of preceding padding slots. >> */ >> struct io_tlb_slot { >> phys_addr_t orig_addr; >> size_t alloc_size; >> unsigned int list; >> + unsigned int padding; > > Even without the padding field, I presume that in > 64-bit builds this struct is already 24 bytes in size so as > to maintain 64-bit alignment for the orig_addr and > alloc_size fields. If that's the case, then adding the > padding field doesn't change the amount of memory > required for the slot array. Is that correct? Both the > "list" and "padding" fields contain only small integers, > but presumably reducing their size from "int" to "short" > wouldn't help except in 32-bit builds. Technically I think we could shrink the whole thing down to 16 bytes*, since just 24 bits of size should still be more than enough, with the remaining 8 bits similarly plenty for a padding slot count. Depends if we think the overall memory saving is worth the marginal extra complexity of packing values into bitfields. Thanks, Robin. * The relevance of SWIOTLB to 32-bit builds is primarily going to be for PAE cases where phys_addr_t is still 64-bit.