Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3263297pxb; Tue, 20 Apr 2021 04:33:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzo9BeC6RlHNzVQJ/DZJoiLlIU0YecvtrPwj5lzaGXmWEORYfWoE/r6g9oN3l7mQKodgmpB X-Received: by 2002:a17:90b:88f:: with SMTP id bj15mr4565180pjb.147.1618918427030; Tue, 20 Apr 2021 04:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618918427; cv=none; d=google.com; s=arc-20160816; b=hiEjyhWgb5VfzVIhlYumrb8BVsQjZA5qUcomhrSx4T0E8uRRo6IwIYo2UHQ9z+PdXK JW0zVXeJ5gbLINt18SeClLJXwzgxEmT9sAO7vZqB9EwyPWTrG54DD1tyrDNcjkJaQcz/ eBIq0jsVG8afDwUIOKaYmKHfQeDKfucEBCh40OjCtYCgbM8BFze2NUP55AobAv4nlcgz d9W3YMKvyxN3fzxhU4oChhIJU7A630OZGf8FS+I6hSmpbfOKYdkt9xw+WyaxGVZtocXI /x/S/XFOFFgOw7/rAcHW4XZkWjnvIctk/4xz+faXiNhEoj1moO0cDkuQ532QuGdaBZKQ wr7A== 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=OtJQAIKOLywPfylP974VGHUtk1ChEQJ4QJMSIhZUTcM=; b=bBKGnNg/S215G/apRNc3vQE3QPSigvBUmIxa3Sc8CavIChe6bL+MbsgaY1sAE+zKR8 r8O2gQuHSWjpgILOfomB5i42BlyQ3x8FMdEocGNDXgUZiPFzGt4WEeUpn4DxVoBugEe9 BUaKz8COVoR24TjQrrrrXjhoNeO6DqmffCaxCoPw7uggw2L1rBvA23fGL0ZFCGCarpwv LbyKvSJEA9ZZ8/Vq3TUVSz0rjAqsks+6UxNr6dA3RwM+/V7/HMbYSFZKv56VfgzC+JQb KiLYkoYFhnf4lnWzsNTshXDFcixKDRP0p1M+o//K8kBb3HKyDMcCjq5oxj1kTQDZ4mRO lwAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=UMJW1hHS; 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 s1si21040324plq.105.2021.04.20.04.33.34; Tue, 20 Apr 2021 04:33: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=UMJW1hHS; 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 S231422AbhDTLdc (ORCPT + 99 others); Tue, 20 Apr 2021 07:33:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbhDTLd3 (ORCPT ); Tue, 20 Apr 2021 07:33:29 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11C87C06174A; Tue, 20 Apr 2021 04:32:58 -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=OtJQAIKOLywPfylP974VGHUtk1ChEQJ4QJMSIhZUTcM=; b=UMJW1hHSEiHIxuYPCmIWqBggcQ 7WzgUBYVndXaDyXAvzCaYB++gpfwEmHNwcJBnPHtzISKsXmtj7AQs66KzH/ShiOiEtQuDh6NS2jIC danHUqryMov77SaH6PzoCADuqO3OzNjDqitfmMV+5e2ij2f/eQn8q0rI3BSCdyVR8nX+Pl804z8dc ldQ6kKGtMIdM7D4SV/a4MiZzQWbt8sK61uwSWkb4CyJGIIQITh5cNWfGAWVtLKBLsiDOb1BvlHnDO 0piIzcx7W6HJ167GMu1pCWEDcEpmybbhNafNeikjjMqwGNrP1EWY58fAR82XU78U2KE8ASVsO54t6 xTFN7DAg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lYoc4-00F6IN-8G; Tue, 20 Apr 2021 11:32:24 +0000 Date: Tue, 20 Apr 2021 12:32:16 +0100 From: Matthew Wilcox To: Geert Uytterhoeven Cc: Jesper Dangaard Brouer , Linux Kernel Mailing List , Linux MM , netdev , linuxppc-dev , Linux ARM , "open list:BROADCOM NVRAM DRIVER" , Ilias Apalodimas , mcroce@linux.microsoft.com, Grygorii Strashko , Arnd Bergmann , Christoph Hellwig , arcml , Michal Hocko , Mel Gorman Subject: Re: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems Message-ID: <20210420113216.GA3596236@casper.infradead.org> References: <20210416230724.2519198-1-willy@infradead.org> <20210416230724.2519198-2-willy@infradead.org> <20210417024522.GP2531743@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 20, 2021 at 09:39:54AM +0200, Geert Uytterhoeven wrote: > > +++ b/include/linux/mm_types.h > > @@ -97,10 +97,10 @@ struct page { > > }; > > struct { /* page_pool used by netstack */ > > /** > > - * @dma_addr: might require a 64-bit value even on > > + * @dma_addr: might require a 64-bit value on > > * 32-bit architectures. > > */ > > - dma_addr_t dma_addr; > > + unsigned long dma_addr[2]; > > So we get two 64-bit words on 64-bit platforms, while only one is > needed? Not really. This is part of the 5-word union in struct page, so the space ends up being reserved anyway, event if it's not "assigned" to dma_addr. > > + dma_addr_t ret = page->dma_addr[0]; > > + if (sizeof(dma_addr_t) > sizeof(unsigned long)) > > + ret |= (dma_addr_t)page->dma_addr[1] << 16 << 16; > > We don't seem to have a handy macro for a 32-bit left shift yet... > > But you can also avoid the warning using > > ret |= (u64)page->dma_addr[1] << 32; Sure. It doesn't really matter which way we eliminate the warning; the code is unreachable. > > +{ > > + page->dma_addr[0] = addr; > > + if (sizeof(dma_addr_t) > sizeof(unsigned long)) > > + page->dma_addr[1] = addr >> 16 >> 16; > > ... but we do have upper_32_bits() for a 32-bit right shift. Yep, that's what my current tree looks like.