From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BA59C433FE for ; Thu, 23 Sep 2021 16:02:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BA4BA610D1 for ; Thu, 23 Sep 2021 16:02:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BA4BA610D1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 18061900003; Thu, 23 Sep 2021 12:02:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1308B900002; Thu, 23 Sep 2021 12:02:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3A1A900003; Thu, 23 Sep 2021 12:02:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id E28D5900002 for ; Thu, 23 Sep 2021 12:02:08 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9C1E682499B9 for ; Thu, 23 Sep 2021 16:02:08 +0000 (UTC) X-FDA: 78619304736.13.56C1C43 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf15.hostedemail.com (Postfix) with ESMTP id 46C86D00009F for ; Thu, 23 Sep 2021 16:02:08 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id i25so28814992lfg.6 for ; Thu, 23 Sep 2021 09:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DLOxhnwH/JaVIhRbDcxcZPpiYGHLJbtd0CRIGAWnOsw=; b=QMXOiJ6n28J2emY/y7cY9+DD4h8Pn0KRvNWmJxYGi/2iw91Mhhsv5k4E/yi6SvFmH+ cwsdxpHCcIaSp+pnaMQx9j8vfDg38b4ujoTb2lzS4jvwjrgaoWuJfcNbrdzMUshkRDfy wyxZpTZP4dsY0GDCSs5bbcT3wFiFu+kSB/Akk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DLOxhnwH/JaVIhRbDcxcZPpiYGHLJbtd0CRIGAWnOsw=; b=E4OeS5YTk4FTGnFhAgbkCzmPg3kwMFc7teXycCauOoWlpQ2RKOuA7pXNbQBssnXjBR 4Y+dgf+QYyMwb484M9+IbbWVUFLZtCh61oAEQUF4J6qrMoqdFQEIxyFvKXQNApfNrfcq oCZe8neJbVA2bU2jG2MJ2qwGK9Diahbh4gJrgAdWeDh1EA24KPjUsdZyb59xXmHDryam +8NEKqgqQ3aN+QrhGV20k0fV2OMj5JOO6u//MPu6ZEFie39u4H/ILuK0D4DqP7VSMvfe T8nVNKkn2fsDP1fLo2kh8NMgzrQrJZVls92SIsjctJH6ihVl8gklsokHAfa/E63lE+EJ E/ew== X-Gm-Message-State: AOAM530rzN5XOjmH6YBn6Tv6HEJ1n2EhIcwhN5jcUd7v66EuIf1VGT/4 Ey3Anm8YK71KiF3Y2RBkcqB+C40uqZ62ndoS X-Google-Smtp-Source: ABdhPJwBJnEJYb3ciCHDrhyJDMWslmLflmEp5Wz8dQt0J4Z64FexHtAs9ElZVoPR2U4OOt9B41HPOg== X-Received: by 2002:ac2:5606:: with SMTP id v6mr4866452lfd.520.1632412925986; Thu, 23 Sep 2021 09:02:05 -0700 (PDT) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id j20sm489939lfu.165.2021.09.23.09.02.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 09:02:03 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id 72so2110399ljf.9 for ; Thu, 23 Sep 2021 09:02:02 -0700 (PDT) X-Received: by 2002:a2e:3309:: with SMTP id d9mr5950451ljc.249.1632412922441; Thu, 23 Sep 2021 09:02:02 -0700 (PDT) MIME-Version: 1.0 References: <20210923074335.12583-1-rppt@kernel.org> In-Reply-To: <20210923074335.12583-1-rppt@kernel.org> From: Linus Torvalds Date: Thu, 23 Sep 2021 09:01:46 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/3] memblock: cleanup memblock_free interface To: Mike Rapoport Cc: Andrew Morton , devicetree , iommu , kasan-dev , KVM list , alpha , Linux ARM , linux-efi , Linux Kernel Mailing List , "open list:BROADCOM NVRAM DRIVER" , Linux-MM , linux-riscv , linux-s390 , Linux-sh list , "open list:SYNOPSYS ARC ARCHITECTURE" , linux-um , linux-usb@vger.kernel.org, linuxppc-dev , linux-sparc , xen-devel@lists.xenproject.org, Mike Rapoport Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46C86D00009F X-Stat-Signature: aopkajdkeux3yc9rprjhwd6oro4hj5yj Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=QMXOiJ6n; spf=pass (imf15.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.167.49 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Rspamd-Server: rspam06 X-HE-Tag: 1632412928-561216 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 23, 2021 at 12:43 AM Mike Rapoport wrote: > > The core change is in the third patch that makes memblock_free() a > counterpart of memblock_alloc() and adds memblock_phys_alloc() to be a ^^^^^^^^^^^^^^^^^^^ > counterpart of memblock_phys_alloc(). That should be 'memblock_phys_free()' HOWEVER. The real reason I'm replying is that this patch is horribly buggy, and will cause subtle problems that are nasty to debug. You need to be a LOT more careful. >From a trivial check - exactly because I looked at doing it with a script, and decided it's not so easy - I found cases like this: - memblock_free(__pa(paca_ptrs) + new_ptrs_size, + memblock_free(paca_ptrs + new_ptrs_size, which is COMPLETELY wrong. Why? Because now that addition is done as _pointer_ addition, not as an integer addition, and the end result is something completely different. pcac_ptrs is of type 'struct paca_struct **', so when you add new_ptrs_size to it, it will add it in terms of that many pointers, not that many bytes. You need to use some smarter scripting, or some way to validate it. And no, making the scripting just replace '__pa(x)' with '(void *)(x)' - which _would_ be mindless and get the same result - is not acceptable either, because it avoids one of the big improvements from using the right interface, namely having compiler type checking (and saner code that people understand). So NAK. No broken automated scripting patches. Linus