Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2095616rdf; Mon, 6 Nov 2023 04:48:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFi+QGMFVXqHTD3ULrViqe6GJ372+F3Cwb/TqU9rGIg/Wa/abw5Hina6emST/zBpWeLNAWk X-Received: by 2002:a17:90a:985:b0:27d:237b:558b with SMTP id 5-20020a17090a098500b0027d237b558bmr22967210pjo.5.1699274889198; Mon, 06 Nov 2023 04:48:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699274889; cv=none; d=google.com; s=arc-20160816; b=0bH1GoRA/YXMXRC7zvba4iPNJU9tclbYNr4lpxGAxvNe9bT+LJMIhvXLF0CHdLRgZg H0vE5qYOIooyCqNWzJQHmG9FLhtCDc+mZhUdqXZSkvD0ZXOzbhQVLO+TaOZ08JsnM2fi 0OlEpgu5oolb78zu/lakhX3ah8UHePKX5cJ3fRbEkBjoPXIZxwFRs2+84jCop/bHlLTn B2DeH/r6K538NHAuQfgRx4Y1yKIXOwNrYSOiaHEOgrvUx8DuZfZ9KV8klfQdNeoQuYhq vNcb08GyItSN2/dUwkTPRpXNMoHiXcxvK+LEutYm+xgqRoz8aL4BU2APWQ2J3OevMjBI QhOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=ucgry1VzZRZY+61I73Kab1MplMNnw+FXQWcxYBPOFtY=; fh=XY1WMDqu05m56lTIzjaDgqFqo9jRQXuj6nq6oEOR3HQ=; b=mhpV5eZUyMoaqcWUaV/lSYxsi8kxTVqTIFXHd6Mev00bKyjx+HxxItq+tcjoGXibns PyhAwN7GDmVtHRiB3x9hmpXWUAI1EARhuRfkUHSQ9/Utn0MVrIV0J9LwGQnYmXQbvFI7 WbV57FAP2WcmhIwJ19nQ95JDvaWNwpnUKg1dvLCMKK+BnlzfJVRvzVvDx6e7I+OOux9v zMESsbVhpMn11RAmnpuc60vFe5HmuGgiH+BJ+M2Ac1CQ0DWh0BEOnne2OMZHmJpXFFYB g5vXlMbLMH3hJgH4AVYIUReN8xiGFscbqVARy8PNvMdXELNUCLY872KBKlJuQbm12uyJ FX5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id oc10-20020a17090b1c0a00b00274c5572179si8655972pjb.2.2023.11.06.04.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 04:48:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 659E78047D68; Mon, 6 Nov 2023 04:48:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232107AbjKFMrm (ORCPT + 99 others); Mon, 6 Nov 2023 07:47:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbjKFMrS (ORCPT ); Mon, 6 Nov 2023 07:47:18 -0500 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F31210E2; Mon, 6 Nov 2023 04:47:06 -0800 (PST) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4SP9kZ65MQz9xHvq; Mon, 6 Nov 2023 20:33:42 +0800 (CST) Received: from [10.48.129.39] (unknown [10.48.129.39]) by APP1 (Coremail) with SMTP id LxC2BwC3pnYu4Ehl160mAA--.43166S2; Mon, 06 Nov 2023 13:46:46 +0100 (CET) Message-ID: <90ea3460-a715-47b6-a151-181e542512e9@huaweicloud.com> Date: Mon, 6 Nov 2023 13:46:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Memory corruption with CONFIG_SWIOTLB_DYNAMIC=y Content-Language: en-US To: Christoph Hellwig , =?UTF-8?B?UGV0ciBUZXNhxZnDrWs=?= Cc: Niklas Schnelle , Bjorn Helgaas , Marek Szyprowski , Robin Murphy , Ross Lagerwall , linux-pci , linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Matthew Rosato , Halil Pasic References: <104a8c8fedffd1ff8a2890983e2ec1c26bff6810.camel@linux.ibm.com> <20231103195949.0af884d0@meshulam.tesarici.cz> <20231106074448.GB17777@lst.de> From: Petr Tesarik In-Reply-To: <20231106074448.GB17777@lst.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LxC2BwC3pnYu4Ehl160mAA--.43166S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KFykWFWDGw17ZF4xtw1fWFg_yoW8AFWfpF WrtwsxKrs0qF13A397Cw45Wwn5Cwn7uay5JrZ09r9F9wsxGr17Cry7tw4Yva48Ar4kZw1Y yFyYvr1DC3WUZ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2Ij 64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x 8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42 xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIE c7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UWE__UUUUU= X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 04:48:06 -0800 (PST) Hi Christoph, On 11/6/2023 8:44 AM, Christoph Hellwig wrote: > On Fri, Nov 03, 2023 at 07:59:49PM +0100, Petr Tesařík wrote: >> I don't think it's possible to improve the allocation logic without >> modifying the page allocator and/or the DMA atomic pool allocator to >> take additional constraints into account. >> >> I had a wild idea back in March, but it would require some intrusive >> changes in the mm subsystem. Among other things, it would make memory >> zones obsolete. I mean, people may actually like to get rid of DMA, >> DMA32 and NORMAL, but you see how many nasty bugs were introduced even >> by a relatively small change in SWIOTLB. Replacing memory zones with a >> system based on generic physical allocation constraints would probably >> blow up the universe. ;-) > > It would be very nice, at least for DMA32 or the 30/31-bit DMA pools > used on some architectures. For the x86-style 16MB zone DMA I suspect > just having a small pool on the side that's not even exposed to the > memory allocator would probably work better. > > I think a lot of the MM folks would love to be able to kill of the > extra zones. There's more to it. If you look at DMA buffer allocations, they need memory which is contiguous in DMA address space of the requesting device, but we allocate buffers that are contiguous in physical address of the CPU. This difference is in fact responsible for some of the odd DMA address limits. All hell breaks loose when you try to fix this properly. Instead, we get away with the observation that physically contiguous memory regions coincide with DMA contiguous regions on real-world systems. But if anyone feels like starting from scratch, they could also take the extra time to look at this part. ;-) FWIW I'm not volunteering, or at least not this year. Petr T