Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3615553pxb; Mon, 24 Jan 2022 13:34:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm9O1GNk26qoH9WrQ81zaTeJLbbj5DxiSBzIQvAT52OtnyPEf24u6ggsYqD8Nclt5NZ85P X-Received: by 2002:a17:90b:1b48:: with SMTP id nv8mr188197pjb.129.1643060091064; Mon, 24 Jan 2022 13:34:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060091; cv=none; d=google.com; s=arc-20160816; b=mVAgYKkniSUNdMDJVIJOMVnHPfu+zHAvG7B0hbqepoCU3rrBGdotLT6t5u7Gapxakx Qf7d4qhiLU9GtT13ZFtKjAYTaZo5IwcB6CXrlUn3QO3IQfy+Q/G97m+F8UqJZsGcK8i8 PwBGWeExJ5jQSP2TLjmxCIu3s7JoYjokSQoZ+IM0UuD6EwFadGw6muATH2hfwqCwB3XH 3KzuAa0tFfJt3s8pcAnmnuWmXe4S+LvUBmEaANNdrDMecg8DglXUBWP5ZgH7kmMh/Eu3 Fyo6rzfCalTvqEuXqEMhQbcgFTkepAC4mGaszegUQKb2XuhlM5g9pyGDLJMPtTprsdzq 8emA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=jYWhV+VmHy4JoS8Y6qW8j82OVebL4OLeZNnZE4AEZhY=; b=GXeIDAgES6sGSzRNRInncvH20XzZS90n8oWcCNvjumwaAbqD036avaokF7SEud3qCX yVHhWHeVbuatEy15o/hQF07rkVnClu2Q/cM/5gVMx0N3hecmQ2hOkPkt6H49hl0InAb7 /tUN2rcR2NtHqDvhURmGnWkuAUpaV3pgzP6sHWj7mC9ZNKtoWIW5pUhlG1/0hqknthq4 ZGk8elTlv/7pKbyIivc6PhgkUngGMpVDRijqd+9Mfq5L07gTU9sFgNtp3qYBHvUGyJxO tEbqi/B03zCIlCxYrbWHoJEiS/LZxsycOwzTWq3DAzGlotxkMEoUD6ouakZJH4eddawG 5Hdw== ARC-Authentication-Results: i=1; mx.google.com; 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 d8si4588355pgc.520.2022.01.24.13.34.39; Mon, 24 Jan 2022 13:34:51 -0800 (PST) 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; 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 S1448127AbiAXVMD (ORCPT + 99 others); Mon, 24 Jan 2022 16:12:03 -0500 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:57501 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1390405AbiAXUpT (ORCPT ); Mon, 24 Jan 2022 15:45:19 -0500 Received: from [192.168.1.18] ([90.126.236.122]) by smtp.orange.fr with ESMTPA id C6DBnl19kAWDQC6DBnQiEv; Mon, 24 Jan 2022 21:45:16 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Mon, 24 Jan 2022 21:45:16 +0100 X-ME-IP: 90.126.236.122 Message-ID: <6a1b84da-d55e-e058-13a8-9920b05ff20d@wanadoo.fr> Date: Mon, 24 Jan 2022 21:45:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] lib/string_helpers: Use the given gfp flag when allocating memory Content-Language: en-US To: Andy Shevchenko Cc: Andy Shevchenko , Vlastimil Babka , Andrew Morton , Mel Gorman , Michal Hocko , Stephen Rothwell , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <1ec96b6e4f2e35599931d7516c6938c4a8845bf0.1642337606.git.christophe.jaillet@wanadoo.fr> From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 24/01/2022 à 15:26, Andy Shevchenko a écrit : > On Sun, Jan 16, 2022 at 01:53:37PM +0100, Christophe JAILLET wrote: >> kstrdup_quotable_cmdline() and kstrdup_quotable_file() are given a gfp flag >> that is passed and used for memory allocation in kstrdup_quotable() just a >> few lines below. >> >> It looks reasonable to use this gfp value for the buffer allocated and >> freed in these functions as well. > > Acked-by: Andy Shevchenko Hi, just in case, another patch has been proposed in the thread related to the v1 of this patch. See [1]. I let you see which approach is the more relevant. CJ [1]: https://lore.kernel.org/linux-kernel/YeU8PhtvvXIWtTk%2F@dhcp22.suse.cz/ > >> Fixes: 0ee931c4e31a ("mm: treewide: remove GFP_TEMPORARY allocation flag") >> Signed-off-by: Christophe JAILLET >> --- >> According to what I've found in 5.16, all callers use GFP_KERNEL, so this >> patch should be a no-op. >> But who knows how it will be used in the future. Better safe than sorry. >> >> v2: Add the change for kstrdup_quotable_file() >> --- >> lib/string_helpers.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/lib/string_helpers.c b/lib/string_helpers.c >> index 90f9f1b7afec..4433e486b725 100644 >> --- a/lib/string_helpers.c >> +++ b/lib/string_helpers.c >> @@ -624,7 +624,7 @@ char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp) >> char *buffer, *quoted; >> int i, res; >> >> - buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); >> + buffer = kmalloc(PAGE_SIZE, gfp); >> if (!buffer) >> return NULL; >> >> @@ -660,7 +660,7 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp) >> return kstrdup("", gfp); >> >> /* We add 11 spaces for ' (deleted)' to be appended */ >> - temp = kmalloc(PATH_MAX + 11, GFP_KERNEL); >> + temp = kmalloc(PATH_MAX + 11, gfp); >> if (!temp) >> return kstrdup("", gfp); >> >> -- >> 2.32.0 >> >