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 9936AC433EF for ; Thu, 23 Sep 2021 16:02:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 833DD60E9C for ; Thu, 23 Sep 2021 16:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242373AbhIWQDu (ORCPT ); Thu, 23 Sep 2021 12:03:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242399AbhIWQDr (ORCPT ); Thu, 23 Sep 2021 12:03:47 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AA23C061767 for ; Thu, 23 Sep 2021 09:02:15 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id z24so29057693lfu.13 for ; Thu, 23 Sep 2021 09:02:14 -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=fNrDfRvTinNO5ssFDqwdgMvDAWTJ7PvbLlXe1M9gew0RGSzcMhFPfvzSBLzoCdFI0f /MIQkuB9/TmwWKSvA6dELc8IjghzU3V52rZPFzddQSc6Q5IihVBVhnCOum2zWdJ0Nz7D EP4fka124zLTsFCCaMz+hKBqBN6+lFTp82AyHDy+hHPRauNNk8b17XQaa7fXwXSNuftM a+ryUyGSXLYf0EPCZNIhgchPtquyV10fi93jSGoEtGNVY38+B2me20EWGHcrp/mFZmuf 2vWsGHIZxlYLu5BF5aQquhFqG7YgBLqdGcnHAQwG13e/U8ho+UZ5yppXzMnqAvnTOEcm 4+dw== X-Gm-Message-State: AOAM533I1bBB8umihglVMODlnIwGa7tvteM3Wgxw5z7TWims7O0t0YBQ wq2vNCPuBDng3NcrZRA1E8DJQ/j9PWUob4gR X-Google-Smtp-Source: ABdhPJyJUwqA7kU4hjAEZJ3OSDAwOiALMmgAaigRKU1HgTCHut7fzp5x0yZj4bNU8VaRlc8g4N+LhQ== X-Received: by 2002:a05:6512:e97:: with SMTP id bi23mr4840268lfb.201.1632412933069; Thu, 23 Sep 2021 09:02:13 -0700 (PDT) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id i24sm629389ljb.31.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:06 -0700 (PDT) Received: by mail-lj1-f181.google.com with SMTP id b36so202995ljr.6 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" Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org 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