Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp713000pxb; Thu, 23 Sep 2021 09:08:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAJHYPSuCTs3zFKVC/yiS++erAWFI+XyxkOd8VnEDW0tTIs+dIOqqJsGeUQHpNawmGUshm X-Received: by 2002:a05:6512:238b:: with SMTP id c11mr4851743lfv.321.1632413300698; Thu, 23 Sep 2021 09:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632413300; cv=none; d=google.com; s=arc-20160816; b=OGrVC76aGe6T5rw+sR4bXl8WVbKXyRd+B3Pd5M6t3xXdSEgOdhB+3Oj+kWwJiD3i6R 669CqcdWngIQHtI29jKvo3yZGsp3kCLfiZvBMIB2O8FEprmIlHtb6a2FIFGW2jmx32dP nO4B/lXCQ9B/EERl7hf+O+S1mKyhQIBAZBxudc+7qCrwks6S8tOi+76RDqWtiDZGpbr9 DekOFuAYNN4g82xLP45MyZGM7ibQfDtAS2uc/hKlGCyZeV4jK8HFXtUZQdiPYYjwuxgg BUD3nyxfKChvY3f0+v7vlF76wDZntATZXpQNNkoBrgXRETK85SGayRENN7CTCbfzonjO Uc3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DLOxhnwH/JaVIhRbDcxcZPpiYGHLJbtd0CRIGAWnOsw=; b=KxNn9OyH9hdozr4Ldg70Kph0ArvkZd1ejM5Hm9kdJrgJ0R2Gbhp3aphFrPnf2Dz9lR E7Q9KNHPSBxk5MzbtzB2rSXOQsndkYbqz2c73jekmXrLPWa7moP5960GxGgcYY7Mf3NB 9lsXwrMquRrlCi0wYm5jaClBTnra5QjBHWw1ql34ZOC0sJY696+2fa+1WNrzi7ipgW1C F111GkLtlfuOqp+jKGP4hLSJcM+rA59DkCEbKIeX4Sg+P6Tp7fCl9Lr+ZlJrkk5OvlWm vBXDyXUnBGK3epVsy+8GrwxVxZ09iJodXJPWUuBT0Fx122+qvNnWNP1XMt2gqBo3U5tw 2pcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QMXOiJ6n; 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 m10si6492234ejl.694.2021.09.23.09.07.53; Thu, 23 Sep 2021 09:08:20 -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=@linux-foundation.org header.s=google header.b=QMXOiJ6n; 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 S242378AbhIWQDm (ORCPT + 99 others); Thu, 23 Sep 2021 12:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242375AbhIWQDl (ORCPT ); Thu, 23 Sep 2021 12:03:41 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E97C061574 for ; Thu, 23 Sep 2021 09:02:08 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id b19so203847ljf.10 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=5jaZQdL+cR6MucRSxJ7b96jFCDGZcqX7/bTbJyGeRFhS8pjvpfSZ6Caybdf24BwSYy qbUNko79z/Ferfd2/13ll76fYqID4TfP5S08I/09ktMolITkFPIze1XLso1pgYmc5RUZ tpjveVyqJ+ZWnOdDlzulPfgp/9gG0Y4ljUPxCcnwbkUw5Vry5DfKUH5e98ctwd/4+EO9 e6MKpv7eUPDWdOypnUCgIxDX1nrAj7urzXEjMUXacgYJZ85bDm2Gqip15BRrKWqgRzWw 5soOp0wcyWXebL3x54Lxx0SF1nsC/FUjTICiFN+5Gi5euaVLALFmVsc2Z6okvxLzaoR2 dPyw== X-Gm-Message-State: AOAM533hbkSHc9rdNBoulkLWZ7dJBJ7KgYJ5UBNlzn09f6HLER27E5ML Gu0F9zsxQxiNSN/fn8ADwN2SF2xzhg4r68zI X-Received: by 2002:a2e:9f0c:: with SMTP id u12mr6180521ljk.92.1632412926524; Thu, 23 Sep 2021 09:02:06 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id y23sm18994lfg.41.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:04 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id a20so201163ljq.3 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-kernel@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