From patchwork Tue Feb 27 07:25:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13573301 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 44851C54E49 for ; Tue, 27 Feb 2024 07:25:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 757734401F9; Tue, 27 Feb 2024 02:25:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 705214401F0; Tue, 27 Feb 2024 02:25:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CCB34401F9; Tue, 27 Feb 2024 02:25:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 495884401F0 for ; Tue, 27 Feb 2024 02:25:29 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E500240B06 for ; Tue, 27 Feb 2024 07:25:28 +0000 (UTC) X-FDA: 81836748336.13.830D2E2 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by imf14.hostedemail.com (Postfix) with ESMTP id 3C5A6100005 for ; Tue, 27 Feb 2024 07:25:26 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=L9QJ4uu8; spf=pass (imf14.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709018727; a=rsa-sha256; cv=none; b=lZz+4dpzH0/NgOQBk3b+ylMp8OVZWxM8L0HHnGj4wvoGfHj4Xtm2gUFPU+FjasOJCPCinC rsR+/R7fVWjxm0irezvSTLKsQt4UodgI2q1AehsZ/sJHZ8SezM8b81q3g2h7pUumhKIRCt /F6qqlq0zd7Mgpujo0LmrR6coKb0m+Y= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=L9QJ4uu8; spf=pass (imf14.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709018727; 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:in-reply-to:references:references:dkim-signature; bh=D7/GAs5gztsadtH3015fa8qhYk0TcWQZMe5LXpw2dAc=; b=XSCQXugzgkeZXdOaH6ftqOOtfNsjqlVTyaKCESE0dv0Wxgj7AaP+Zb9rNbZ9Q10KLnzXsD ttoOtOtLwn3bTSFfJUpuyN3pnREnB5UV46PqcecgH4yHnGvEK+PhuRG7d0LcHMxjkaDkWg zP/YT0lJVazQ+cTYjfICinC3Fr61aRA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709018725; 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: in-reply-to:in-reply-to:references:references; bh=D7/GAs5gztsadtH3015fa8qhYk0TcWQZMe5LXpw2dAc=; b=L9QJ4uu8+ZG9wL4X+YEPIZzj0j5nvTyBQaGmpC2coWTgnvvZMpscuq6nz3wKwMmtt4hMgU oGgArp3JItZrFTcOmGlIr73VBYMArf2UtOhL7tIOh9hYaCmx4mUKBhAnK+c/9znpTwN3JW ujnGlknhvUMq0I+x0QB6HvM98+tr4to= From: Kent Overstreet To: linux-mm@kvack.org Cc: paulmck@kernel.org, Kent Overstreet Subject: [PATCH 2/2] mm: __kvsize() Date: Tue, 27 Feb 2024 02:25:15 -0500 Message-ID: <20240227072515.3736069-2-kent.overstreet@linux.dev> In-Reply-To: <20240227072515.3736069-1-kent.overstreet@linux.dev> References: <20240227072515.3736069-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3C5A6100005 X-Stat-Signature: a1ib6eaq8agzxgpjgp5if8dadugkic4a X-Rspam-User: X-HE-Tag: 1709018726-989501 X-HE-Meta: U2FsdGVkX18PfsCY8cagrcNt4HudjD/5uRmjBrtSNoZ/EHAsx5dcP5l1dYgaNRN1cXciYIleFbJkrTNMtemzNsq/oTjgG15uArIQ/o0tT+Uw5cKQ278DlBBTSjPR63NU3wLCxdeyyLK7CjRJE4TLHTRbvStl3nUFx4GPylk3GupqHJd5JKtop/2x1mhuxSwissBV69dS7gJT9pouMDmTkQUi/DhMb70sLT+qkpMVrVZILo14W91Mqz/S3CYOUkaodwPOi9le22EhlpZghfR8OKXAUxMAZ0ZLPJI1lnjCp4iGG8ns9c3R+5T6hQ4xMq9P9PUtQHdtbwP6b1dVisYgt0W6ZN5QpqjOcOUPJsHWuaK5DbpuDWY1RdShDjYrBjG+K+U1NGEvPRvkU0v1e5a7lawG2bBO9wxmbnLc7fshdg8XI0N8asS3PuJkcWZvl4z5owEoi1tMJWwwtSMG/pWRihbVl6qhZLkpXskgRbAVatKsYxww5X0tKJNtAJgndV4uVHAQmafeSfv9kWVQMsbNWexlAsHUHbh9Uy0lSQTMz0yUwjF6ktCG4NUdjNHzETMZ5ByjjPQkl8oYJl4eQ8IVCRZFhWEh+rRph0/4Q4dHcvFfKnz2HwAmFZ5EgbMVEp5OAqtc9UP6FmJgXhV3/68e3Bhtpq0jZpAPGwPt7YAWKpagnUshjS3flEluEW4SjKyP2TpaLt95GorJpmESNdlArO4Hkkcc8T3rTcEVSbk7woJPb4DXPUTXFDZO6C9l0T5xQOmQ+szVGNt2XbbHbyJRfkYNrgUU+JtJ8uPF5cqByJf6/kRawRed+ozOS6kO3n2+E2Vsu4mw05fElzhULPdS+kkJI0spVyEyLmiiZQZwfq93IylPKn1WLlb4RQO1n1YY5HZnzRzfnU4yA6PJ2+GwnjI1hzrLf4Fyzpq2QfVyFhubJ36SW5uXnmNBPKjymzxWghiqtISaPQh9MtCoZR3 FA63TxtN RG2I85z4uZD0FJuiYIeoUV3xPUJ8s9xY4/C4T3bSJavL+0LsvFuY5I1xbfaLmsJnXn48+Z9umH2o2vkdcdJQ5gvOFLd142K2XUCRT2y++p2hVdfTtxDIGPyz20yLSEqOZnt+QYQ8W/MrFrHDF+//1DSCkLTQg0VsDqNXwC+0fBNyi10+gszK87D84mg== 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: List-Subscribe: List-Unsubscribe: Add a __ksize() equivalent for kvmalloc. Cc: linux-mm@kvack.org Signed-off-by: Kent Overstreet --- include/linux/slab.h | 1 + mm/slab_common.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/slab.h b/include/linux/slab.h index b5f5ee8308d0..9ef26837c72d 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -227,6 +227,7 @@ void * __must_check krealloc(const void *objp, size_t new_size, gfp_t flags) __r void kfree(const void *objp); void kfree_sensitive(const void *objp); size_t __ksize(const void *objp); +size_t __kvsize(const void *objp); DEFINE_FREE(kfree, void *, if (_T) kfree(_T)) diff --git a/mm/slab_common.c b/mm/slab_common.c index 238293b1dbe1..6ec0f6543f34 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -972,6 +972,19 @@ size_t __ksize(const void *object) return slab_ksize(folio_slab(folio)->slab_cache); } +/** + * __kvsize -- Report full size of underlying allocation + * @object: pointer to the object + * + * __ksize equivalent, but for kvmalloc + */ +size_t __kvsize(const void *addr) +{ + return is_vmalloc_addr(addr) + ? vmalloc_bytes(addr) + : __ksize(addr); +} + gfp_t kmalloc_fix_flags(gfp_t flags) { gfp_t invalid_mask = flags & GFP_SLAB_BUG_MASK;