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 7E4A0C433EF for ; Thu, 23 Sep 2021 16:08:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B79261107 for ; Thu, 23 Sep 2021 16:08:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242425AbhIWQJ5 (ORCPT ); Thu, 23 Sep 2021 12:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242421AbhIWQJ4 (ORCPT ); Thu, 23 Sep 2021 12:09:56 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B12C061574 for ; Thu, 23 Sep 2021 09:08:25 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id b36so239440ljr.6 for ; Thu, 23 Sep 2021 09:08:25 -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=Tv2p1LLWc72dzX7OiBdxoZiYVtK16vSlnvgZ3fUhgAIiyBaQNLTyAgjOx0Xri3z1vv dDt2PW4msykHyasODwDRgOpKkwZX/XTIGqtL9xsEiFFgYgrlhiPhpu5kN1LQKMXziYKD xNlEs9X21MAdEMyQHIVu5WEsbP2Fv2Iu1EdLpgUj5cRATdwtPCyP/HjEbVVFI+faB0aM fpMPzALzNvKE7tUjT4s3sY5syCxXskkhov6XG+VwwVqRFUDdRWABXUXFvu8XFVH8zFLk 7qpdSJUZLlFGBI9F/JwRlcirx88gNYyzdzG06hObxs3qpi+iUNgD5i0lH/tRyCK4k9bI 5+Gg== X-Gm-Message-State: AOAM531ZTOhelkn2hDkkdfQ5qUrnKoJfDjNI6TvmFY5TZBDGXuF6S/13 JUh28/8LZEO/6RkZO6ojPwxmvPEmdmNdhhGyW/M= X-Google-Smtp-Source: ABdhPJxDnlLDPWNzMZuWcnV+/rOgrakre1rXPCpfdqmIqed3vqPY4L03tfWY5TgXHtZ8fOcJhFFSsQ== X-Received: by 2002:a2e:b608:: with SMTP id r8mr6073109ljn.248.1632413302815; Thu, 23 Sep 2021 09:08:22 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id b17sm639414ljj.35.2021.09.23.09.08.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 09:08:22 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id e15so28571128lfr.10 for ; Thu, 23 Sep 2021 09:08:22 -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-s390@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