Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4109767imm; Mon, 30 Jul 2018 08:50:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeBREsc9g3Zz6/VZx/jRZZXvWyntnMvm8i5RACgZMArzXT1Sgk9fdk5mzW6oOCgmSEBWXrh X-Received: by 2002:a63:f713:: with SMTP id x19-v6mr16793964pgh.233.1532965805974; Mon, 30 Jul 2018 08:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532965805; cv=none; d=google.com; s=arc-20160816; b=csdQUsndKCav2Ezvrnb4Ca0bsmsGaojwRi/4s1AHs3ZtfPqJ8VFf9pXkC+cynoM02f FAyQI3K4ar7zkSkoUss7ahCtLmSbFCp6z2UGpe6rBIH5B5IG38Whbd8U4IXSJklj1vvU vVoLNP8hucEyCRz4s5ScpIh2ZvY0n2QLE2jlj/HFOqM/gL6BG7SfUK80irsBYYyQ9ebV ZV33IoI/Q1JCmOihsUSkC8xriGO0/5FMMJNePBaxvxFYO8D/Eoq/49lJiFzSNg3ehHft 6O2uQt5WDcgeNiBVyClDgkHPgYQKimLOdOuMfhmiE9o9Wj3KtRsYDcpHwiXjr6JSex0V FgeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=BPyHhrOaQI6gykkvq7PQcU1uKoBze/UmQjletNVwDBA=; b=qDxzgnFO2W0pjt4pgETfA74SebfK1pOd+Gy8ihzOlpPq2WmHKznOPh1WmyzgTuehx6 9hCcvgJUUXBQsrq0iDpx5KJXgDA9QsksLqPp+H9pvawyZZ5NSwHhbH/sq/nYbzAjjTpC EajbR9XZoy7v3MJMpFi4fXGz6snpNifHlFIWD+LHyrPiUfqBR3QwlikG6bLDArEbMSkh RpiNhqOTVtGUBdK5ysOHSvHCwlKm3h7yKNm1HqfxUJulLsksAYyZsv6lhvK14Rq3jIkY du9h+yGisA2Hz3RlmC1LRAVaAazqnTOJ+MAS5rBWLZRFuaRUEHUCEKiAUftld4fKSk/f XyuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=eUfyceB4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x185-v6si11383263pfb.306.2018.07.30.08.49.51; Mon, 30 Jul 2018 08:50:05 -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=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=eUfyceB4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728666AbeG3RYb (ORCPT + 99 others); Mon, 30 Jul 2018 13:24:31 -0400 Received: from a9-54.smtp-out.amazonses.com ([54.240.9.54]:39754 "EHLO a9-54.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbeG3RYb (ORCPT ); Mon, 30 Jul 2018 13:24:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1532965736; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=6MeMP/6oTP7C9TopqhPYMKdGbFexjggyz+7JZB2GpJo=; b=eUfyceB4qAm1Vyrsc2suqewJrZUEID8UHDTPKfjpqpc9uy4ogzptN3O9wjGuTyb8 dT5LVkIwIsYhBIxTriw6PkdIEExX+DF92iSIpDcJ14KdbA5FmDVN6k+e2ia4RWjVaSd gbIHiqKEQRmJTCnzP+qzU2TqLFYGlUJw1RvNAfLs= Date: Mon, 30 Jul 2018 15:48:56 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Vlastimil Babka cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Roman Gushchin , Michal Hocko , Johannes Weiner , David Rientjes , Joonsoo Kim , Mel Gorman , Matthew Wilcox Subject: Re: [PATCH v3 7/7] mm, slab: shorten kmalloc cache names for large sizes In-Reply-To: <20180718133620.6205-8-vbabka@suse.cz> Message-ID: <01000164ebe0d06f-8f639717-8d32-4eb9-9cc1-708332b12ca6-000000@email.amazonses.com> References: <20180718133620.6205-1-vbabka@suse.cz> <20180718133620.6205-8-vbabka@suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2018.07.30-54.240.9.54 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Jul 2018, Vlastimil Babka wrote: > +static const char * > +kmalloc_cache_name(const char *prefix, unsigned int size) > +{ > + > + static const char units[3] = "\0kM"; > + int idx = 0; > + > + while (size >= 1024 && (size % 1024 == 0)) { > + size /= 1024; > + idx++; > + } > + > + return kasprintf(GFP_NOWAIT, "%s-%u%c", prefix, size, units[idx]); > +} This is likely to occur elsewhere in the kernel. Maybe generalize it a bit? Acked-by: Christoph Lameter