Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1226819pxx; Fri, 30 Oct 2020 05:23:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAOOr6oMZHUEgK79t34+CHsqmb/dsDXkXysyJduUx4P1BdRU3uAxY9v4yaj2YZD1CAm46g X-Received: by 2002:a05:6402:1586:: with SMTP id c6mr2074402edv.84.1604060630853; Fri, 30 Oct 2020 05:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604060630; cv=none; d=google.com; s=arc-20160816; b=yX5HmGZJ04NwhKTPQ64zE4XjvicSW4m7CSJkNk0ob4/lbreJyCDn8RqZceJJj6uqxA eQjTSc0kAVUc7wAP2aMak+hzdVKweqsyh7tS6+WwUQ8ANG9qBc6rVMVgwporGTkI4EIS 6Ff4GS2fxYXwtxYRC/Mon0CsM59XlVZ92MSTSLxo8AnbBR7Lnl8QGfxAMtIf51ZxUuzQ piyAY+W74MrgbMUfY4K6r+7zTycNwMv6XNDDMPO/LlF8ve9NhJLoBctlB8gdjAG+9wXd /Zz2u8IbgOV1pSrpVCK0YFX2o6SuOZs4M0Hh2a1qii7Z21pQVqBZNvgxOhRSSNf/1f7m 5XZw== 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=yCKWkz6WsiFrJUW0f9hCTQKUvyKMyz6Kme4fPCErzMk=; b=zoaepydNG77xybh2ENa/w7+ZCVdQgq45bCnoNPSgzlnmb26ky7V/mywf7H/NiVxEro iw0AJ5PWSc/XSA648KH+tWR227Jgtg+tfNJt1k9BDZhCWvt0b/0cPyb4eNOhSaI1ku0J 4Cda7Zi9V7rxjVK7ixLt1nAk45mCD77J86Vu9eRVwVwB+QHkNyC7Gf2vvFJy4itxcWC9 +iIiFXZP/acMX7u4zBwEjvUtgxNijnBBm8de9DbI6xcHzQ9qE4eO/BOcCnlWf1BFUILY MYQqGSwZ9Cn1qNEflB9i0s8rfOleG+x2ZP/c3O+fcHxkIGLVog1OaH0bfEFidq9hloZu gwTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=HELDt+tc; 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 g27si3993685ejd.639.2020.10.30.05.23.27; Fri, 30 Oct 2020 05:23:50 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=HELDt+tc; 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 S1726575AbgJ3MWG (ORCPT + 99 others); Fri, 30 Oct 2020 08:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbgJ3MVN (ORCPT ); Fri, 30 Oct 2020 08:21:13 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B459C0613CF for ; Fri, 30 Oct 2020 05:21:13 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id s15so8294972ejf.8 for ; Fri, 30 Oct 2020 05:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yCKWkz6WsiFrJUW0f9hCTQKUvyKMyz6Kme4fPCErzMk=; b=HELDt+tcVG9L3FE/J2f9SWBNccZarXz9UfbOm7YD1rQwIjLP/0vg56ErKLexeBW8sm mAFVsZjE5XfkAO1q88Vixk09s/9NonMe/UM+n+F9G8KT6d8OjomKa6v2ECYUGTAJfgN3 A5E5H/CZNDC+752lzKX+wzbF+GPu2Q2GBEH7ssg4mchVzX/OK0cXurqHBOMXs/kxRclm ILLLQ5jvR68/BTTmyCqbp6P8v2+nSBO0Oyax+QsxmCZgXdKHxu7z0wiI3VRwksT01jv7 Sk7yuWkl+MiEdmDuA+Mzuhb4nLUAAmQZoKRso/Oh8J0v/k/C5nG/OeR4jegW8HRSeuCV sKKA== 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=yCKWkz6WsiFrJUW0f9hCTQKUvyKMyz6Kme4fPCErzMk=; b=Je8X/xcf/ABBORmHPV+00+mAvyShZELdks2Va69PBS0uqbtR+IU7TKc8/O+CwdZcu8 h5owylLUorkpNABVOgqLAt09xLdWpjXFt+s5o8wrqKzXbF0faGzdPwGNoIxBD/U9i2UC Sd+5Za0VgJjIC76X2nM1gBEpPi1EsNu4QthGQtYlBPgNkOOog1SivgRtuCvE/v6Z1Y8K 4fy/KMhpluE80fFqAIx3FGxqlHLcQejWy3wXzVICClnZPAmIH1NSuPp6CBYMR/GMdE9F H1dqDupvWDWzQG4MWSzOFCJ+OkY1mOl4oS9EBwrEYK2mjFRy1n1mCtnKD3+qGuGlejUr Yjzw== X-Gm-Message-State: AOAM530MzWYTt32doHncV1fUe8RQgGNbC+x7qHkN8jMXhaZVhiyYtW5O Eb8GV9zYB9SZH/VAYpmktDyqaUYkjXqcsQjwcH4v1Q== X-Received: by 2002:a17:906:b009:: with SMTP id v9mr2291539ejy.155.1604060471862; Fri, 30 Oct 2020 05:21:11 -0700 (PDT) MIME-Version: 1.0 References: <20201026122728.8522-1-brgl@bgdev.pl> <20201026131427.GF4077@smile.fi.intel.com> <20201030105706.GK4077@smile.fi.intel.com> <20201030105834.GL4077@smile.fi.intel.com> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 30 Oct 2020 13:21:00 +0100 Message-ID: Subject: Re: [PATCH] devres: zero the memory in devm_krealloc() if needed To: Andy Shevchenko Cc: Bartosz Golaszewski , Greg Kroah-Hartman , "Rafael J . Wysocki" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 30, 2020 at 12:03 PM Bartosz Golaszewski wrote: > > On Fri, Oct 30, 2020 at 11:56 AM Andy Shevchenko > wrote: > > > > [snip] > > > > > > > > > Any use case? Because to me it sounds contradictory to the whole idea of [k]realloc(). > > > > > > This is kind of a gray area in original krealloc() too and I want to > > > submit a patch for mm too. Right now krealloc ignores the __GFP_ZERO > > > flag if new_size <= old_size but zeroes the memory if new_size > > > > old_size. > > > > > This should be consistent - either ignore __GFP_ZERO or > > > don't ignore it in both cases. I think that not ignoring it is better > > > - if user passes it then it's for a reason. > > > > Sorry, but I consider in these two choices the best is the former one, i.e. > > ignoring, because non-ignoring for sizes less than current is counter the > > REalloc() by definition. > > > > Reading realloc(3): > > > > "If the new size is larger than the old size, the added memory will not be > > initialized." > > > > So, supports my choice over yours. > > Kernel memory management API is not really orthogonal to the one in > user-space. For example: kmalloc() takes the gfp parameter and if you > pass __GFP_ZERO to it, it zeroes the memory even if user-space > malloc() never does. > Ok so I was wrong - it turns out that krealloc() is consistent in ignoring __GFP_ZERO after all. In that case this patch can be dropped. Bartosz