From patchwork Sat Oct 8 02:03:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 13001581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE278C433FE for ; Sat, 8 Oct 2022 02:03:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A0E46B0072; Fri, 7 Oct 2022 22:03:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34F8E6B0073; Fri, 7 Oct 2022 22:03:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 217EB6B0074; Fri, 7 Oct 2022 22:03:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 10BEC6B0072 for ; Fri, 7 Oct 2022 22:03:31 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D6D8A1A06BF for ; Sat, 8 Oct 2022 02:03:30 +0000 (UTC) X-FDA: 79996135380.28.0766035 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 8A71E4001D for ; Sat, 8 Oct 2022 02:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665194607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=YD1fTxgY2o9DCFb1V0sfmRfUUrcgW7r49fbNShbAR5Q=; b=dECaWPZltt2e3MdeMkXVxiFwt8tSSuSRDFGcuYawLIqw2YhH76mUY0R9XYSXWfHdFNc/ov KCzLo1skSAIZ7aGOxdHIcBzDbefW9+TVNtF3Zcqf+hFdf8k/nIdySj6LWttriodoF2Ak+4 /jXcN0P205NPemF1qYOcDIMQy/NDab8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-Ufjlb0awPO-I2J3CZeuVDg-1; Fri, 07 Oct 2022 22:03:24 -0400 X-MC-Unique: Ufjlb0awPO-I2J3CZeuVDg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A554C95D683; Sat, 8 Oct 2022 02:03:23 +0000 (UTC) Received: from fs-i40c-03.fs.lab.eng.bos.redhat.com (fs-i40c-03.fs.lab.eng.bos.redhat.com [10.16.224.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 204ED145BA60; Sat, 8 Oct 2022 02:03:22 +0000 (UTC) From: Alexander Aring To: cl@linux.com Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cluster-devel@redhat.com, aahringo@redhat.com Subject: [PATCH] mm: slab: comment __GFP_ZERO case for kmem_cache_alloc Date: Fri, 7 Oct 2022 22:03:12 -0400 Message-Id: <20221008020312.1932347-1-aahringo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665194608; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=YD1fTxgY2o9DCFb1V0sfmRfUUrcgW7r49fbNShbAR5Q=; b=itV1lWFE2gsrye5gZR7ShYcXwRufqaO7KEeVy94znpQJ7RIevM1UGF0K1XxrJEmwwN0OZ9 UF/sEYKBHfHTrsuit6D2GPYKD6O2YnMaRwYkSAVXZHmVZ5NFRxCrd3rccKqhkpZvLAbcYl k6gLMrDns6HraPmgIf0jhWSRxbXHWGk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dECaWPZl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of aahringo@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=aahringo@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665194608; a=rsa-sha256; cv=none; b=63gQNmye92Kbi/SaZfobtESATvFKBFIdKq+TL4jEgRHDuQXGDRSgPIqyi6EVdhC6a8M9Mq fRP05Ew8sFRyEno9Uso7vDAa2hmI/Ckmdz4/ydaO5f9tWdtjBk5+qPA4ZZAm8UeUYmOBKi 4Z42c8TQ+xfvZtKkk8kt8azh2aiAASc= X-Stat-Signature: hahfgfre6z6h1m93gc86yrnk13hssf4u X-Rspamd-Server: rspam09 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dECaWPZl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of aahringo@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=aahringo@redhat.com X-Rspamd-Queue-Id: 8A71E4001D X-HE-Tag: 1665194608-350765 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This patch will add a comment for the __GFP_ZERO flag case for kmem_cache_alloc(). As the current comment mentioned that the flags only matters if the cache has no available objects it's different for the __GFP_ZERO flag which will ensure that the returned object is always zeroed in any case. I have the feeling I run into this question already two times if the user need to zero the object or not, but the user does not need to zero the object afterwards. However another use of __GFP_ZERO and only zero the object if the cache has no available objects would also make no sense. Signed-off-by: Alexander Aring Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slab.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/slab.c b/mm/slab.c index 10e96137b44f..7a84c2aae85a 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -3482,7 +3482,8 @@ void *__kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru, * @flags: See kmalloc(). * * Allocate an object from this cache. The flags are only relevant - * if the cache has no available objects. + * if the cache has no available objects. Except flag __GFP_ZERO which + * will zero the returned object. * * Return: pointer to the new object or %NULL in case of error */