Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1618721imc; Mon, 11 Mar 2019 18:58:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxE6NNfVe9ylM31p/pu7WBnw6SzvlBMoJi57NsUXfbQuYWaibX3CoZDW2evgBlcwADzLLs X-Received: by 2002:a63:f407:: with SMTP id g7mr32660355pgi.413.1552355929745; Mon, 11 Mar 2019 18:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552355929; cv=none; d=google.com; s=arc-20160816; b=FyVPjOrVI48b/akQCpPZvIhc+8Zvdu0r5zeUto6/Su2mm88uzMcJDoDSWhW7OkcEFY umBToij2g0p8Wns7XkHKYG+/VGu0vV1VjSwEt4KKvVJJLsdxIYFgYqMbggDmX2f1XmHU K6oYiO/M1Ogz/iAQc4TKbGetwP+EoSlyq+hpA5+iKQ5q8DQVkd5BX8UVt0PVAK75Q983 fXK6TYmBmOxZFAAKoa3urOoHT8HKLMgFM3g1RA8Boa/q5NtY2kr9CG+h3t8ViSc0z+iU gxm0xp9YGXKX68tKMGIxxRjO+emmU4EjyYAFLAgsmszBBzf6oGMZMpZpO/KwM4Vp1oHu iyBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=04Cjv9Dobjc3gTE2CQiiLdUkyBY+xIpz5hgmSh15OBE=; b=bzHijqbrqEEh8J4UbM+5wu9jkOHB6j4E0v8jLDfGmE//3NfgTy63MeHw+rhuUIahM5 joeGNGIgNB+DnwD8z3Kv5HeEvLJWDKBymiy6RDkIT/Lk236e2gWpZ80ZOXCmvv38j4iU c8AmvxHWRJvvghCfshsoAtp/1WrhJMQUll6rIMguFtTcmFek9PoToxb5JNV0IQm/0xVI n/eWnsc7Qd7MvIgK3KjunazcfL5koqWVD1yg7nbLxWAw/IQmEpm+9P7xH/H3e7p9SLBV gX6lLmm0ovHTKpE0guxZijU8HpuuugLAptpDKocSN0Z8cM3c3itvleGzs9HcZDrxCVjm UgSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AI1aZ9ak; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si724482plv.424.2019.03.11.18.58.34; Mon, 11 Mar 2019 18:58:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AI1aZ9ak; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726797AbfCLB6O (ORCPT + 99 others); Mon, 11 Mar 2019 21:58:14 -0400 Received: from mail-ua1-f65.google.com ([209.85.222.65]:42667 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbfCLB6N (ORCPT ); Mon, 11 Mar 2019 21:58:13 -0400 Received: by mail-ua1-f65.google.com with SMTP id s26so261307uao.9; Mon, 11 Mar 2019 18:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=04Cjv9Dobjc3gTE2CQiiLdUkyBY+xIpz5hgmSh15OBE=; b=AI1aZ9aklgB5/zpChAhzEkROfTeOGXpQHMIirfg5c2iVgBDsGfvCe6cl7zXLIlKLf6 v22Nf227bjpfkufraf3ROUqh7Tzi0DlVLP/Z38RgDAw+srBfK0cQ/SOhEYIRQdkpCRcz am8FvVx723ATlCft4FTo0TMeLhYOV4ttbTQfxcbB/YgLmXrKQGXCvJ+58/wURUPKZq3y rTxNqLYjh7keUILJfFEXcFT4FaynKNw6EIlfTrzUn5EnSiZiPHFMqMdRQJv+TUdVl7d5 7CXxcStbkdn7vCpU956FiHy6bqj6b1bUA/M1/es/i/vUVCXODLoLgZknRo+NxJNs8t7P pF7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=04Cjv9Dobjc3gTE2CQiiLdUkyBY+xIpz5hgmSh15OBE=; b=lzp+PZGpXVJI66FWV3605Waos4N7V99W73CTOr8FcZYlXKVveeOVOuu1yL+Ul84YmS lVh45vnFPXe8uNO4B4bnBJAyCjjvKPheirCNyJg24+aaqhC+T5TOlwGvSPy7KDg5tqJQ ZSPfr9iQpqIs1UycV2v/Md+TlYNmSnM0LrCN0OUS+m/ycgmthElkFZz/NAbPkbORhiEV 8H3AvkJvnOx8kYDQKIb7hTAY7bBpVi/FEp2UcMRFutaFdDk9AinRwW+C8wKD5hgg1w3Y wllQCVKxvurc3NXQz7fi97aZlPiejnCiyYjeA1wAn3obvTqNKqXVWkngQWkpF5a8GbIG UCAQ== X-Gm-Message-State: APjAAAVfm77CTEoBqAK127FC+T7rLUfiHeEIGNEBtJ8iUJAdhLliaENG f7aSVUcWAhS+W9UZoGcpfnffkPVm4GtJ5yFQzh6yzJgU X-Received: by 2002:ab0:73da:: with SMTP id m26mr17322497uaq.71.1552355892360; Mon, 11 Mar 2019 18:58:12 -0700 (PDT) MIME-Version: 1.0 References: <20190219074500.16454-1-vichy.kuo@gmail.com> In-Reply-To: From: pierre kuo Date: Tue, 12 Mar 2019 09:58:00 +0800 Message-ID: Subject: Re: [PATCH 1/1] of: reserved_mem: fix reserve memory leak To: Rob Herring Cc: Marek Szyprowski , Frank Rowand , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi Rob, Marek and Frank: > > > The __reserved_mem_init_node will call region specific reserved memory > > > init codes, but once all compatibled init codes failed, the memory region > > > will left in memory.reserved and cause leakage. > > > > > > Take cma reserve memory DTS for example, if user declare 1MB size, > > > which is not align to (PAGE_SIZE << max(MAX_ORDER - 1, > > > pageblock_order)), rmem_cma_setup will return -EINVAL. > > > Meanwhile, rmem_dma_setup will also return -EINVAL since "reusable" > > > property is not set. If finally there is no reserved memory init pick up > > > this memory, kernel will left the 1MB leak in memory.reserved. > > > > > > This patch will remove this kind of memory from memory.reserved, only > > > when __reserved_mem_init_node return neither 0 nor -ENOENT. > > > > I'm not sure that un-reserving memory on error is the correct > > behavior. It may be fine for something like CMA, but if it is some > > shared memory used by another processor in the system not reserving it > > would probably never be correct. > > In this patch, we un-reserving memory ONLY if explicit compatible matching fail. > That mean driver found something wrong while matching and let OS know. > (But reserved-memory without compatible property will not be affected.) > > So per ur explaination, there would be cases that driver reported > matching memory fail, > but the memory is still needed by another processor? Would you mind to give some comment and suggestion for this patch? Sincerely appreciate ur kind help.