Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp179445pxa; Fri, 21 Aug 2020 04:39:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCRoomh4ORKtrjskkqvEyKC97XWMHpblDsdykAnc8jtro3DGHpkBfXoW4OsjXwxxUgUiq+ X-Received: by 2002:a05:6402:1151:: with SMTP id g17mr2374895edw.227.1598009959059; Fri, 21 Aug 2020 04:39:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598009959; cv=none; d=google.com; s=arc-20160816; b=s+ywbLTIOy6Qj7DXNaRFc2CNRO/8sql+g/IfQB7JLLUY/xxniM41ZmMI0WYyvmfTaj 7fThOUgZh8jV0SE4XrHkHpc2YR/yUcLV+4Ey8zcAPgXM7WekjlUuksIfYOUdPLAuHyyB JNtQoQv7U1GXyafczHkqEWKx+rivDT1BAGNHLJpeHF74ijNdZV+uAeDaV46zyzR+kDAd 72X8HYTJOXpzTRBJYVc808KxUHzaP8Bw4axrC5HfelcKvnVVKhWOYmO4U2d4oUP/NBnd RWKfxpmt80JY4Pq2aca6ivhRnLpSNwxwg1AvwhBlm7CJ+QplCqgTrlqqfj5WHlRdGR9e nJXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pFzRNm3nz9/vOH/zIeWlz2IfOrJmfSArM9Bd1OH5fT0=; b=DmtZC2gUuPJeuqAjgjFuxyhItblww0rFwFU6QOnHsniUBmpKWcEj6Aqh32wuOmqB11 Bx3Ch2uE9SZf83tcOSxBrhgXuoiPS/smtroezVpca8HtJW02zD2vPkJCFDctdsGq3P3e znyOqyhps9ouyVvaLxmHW+IBpJO2UhJ0t1ak/r7YW3noXjT19E4ZjfB4lydG+edcDcsf 1VBHiir2GcfGhZgCIApLXOoXX5t0hoMf4poQXUJQGlDqn20/AJ0AQM3m3l95U7e0/Fb6 lWUj11vKYbYEQ9rWbIk0/8L6VG5e0GvvuBidRO3J7HPfH6mAoNlpktaojcFDgZAl1bI2 61hA== 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 s27si1360353edi.266.2020.08.21.04.38.56; Fri, 21 Aug 2020 04:39:19 -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; 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 S1728254AbgHULh5 (ORCPT + 99 others); Fri, 21 Aug 2020 07:37:57 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:10300 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727931AbgHULhG (ORCPT ); Fri, 21 Aug 2020 07:37:06 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6EB9571D0E991F6D9C19; Fri, 21 Aug 2020 19:37:04 +0800 (CST) Received: from SWX921481.china.huawei.com (10.126.200.129) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Fri, 21 Aug 2020 19:36:58 +0800 From: Barry Song To: , , , , , , CC: , , , , , , Barry Song , Mike Kravetz , Roman Gushchin Subject: [PATCH v7 3/3] mm: cma: use CMA_MAX_NAME to define the length of cma name array Date: Fri, 21 Aug 2020 23:33:55 +1200 Message-ID: <20200821113355.6140-4-song.bao.hua@hisilicon.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200821113355.6140-1-song.bao.hua@hisilicon.com> References: <20200821113355.6140-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.126.200.129] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CMA_MAX_NAME should be visible to CMA's users as they might need it to set the name of CMA areas and avoid hardcoding the size locally. So this patch moves CMA_MAX_NAME from local header file to include/linux header file and removes the magic number in hugetlb.c and contiguous.c. Cc: Mike Kravetz Cc: Roman Gushchin Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Will Deacon Cc: Robin Murphy Cc: Andrew Morton Signed-off-by: Barry Song --- this patch is fixing the magic number issue with respect to Will's comment here: https://lore.kernel.org/linux-iommu/4ab78767553f48a584217063f6f24eb9@hisilicon.com/ include/linux/cma.h | 2 ++ kernel/dma/contiguous.c | 2 +- mm/cma.h | 2 -- mm/hugetlb.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/cma.h b/include/linux/cma.h index 6ff79fefd01f..217999c8a762 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -18,6 +18,8 @@ #endif +#define CMA_MAX_NAME 64 + struct cma; extern unsigned long totalcma_pages; diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 0383c9b86715..d2d6b715c274 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -119,7 +119,7 @@ void __init dma_pernuma_cma_reserve(void) for_each_online_node(nid) { int ret; - char name[20]; + char name[CMA_MAX_NAME]; struct cma **cma = &dma_contiguous_pernuma_area[nid]; snprintf(name, sizeof(name), "pernuma%d", nid); diff --git a/mm/cma.h b/mm/cma.h index 20f6e24bc477..42ae082cb067 100644 --- a/mm/cma.h +++ b/mm/cma.h @@ -4,8 +4,6 @@ #include -#define CMA_MAX_NAME 64 - struct cma { unsigned long base_pfn; unsigned long count; diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a301c2d672bf..9eec0ea9ba68 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5683,12 +5683,12 @@ void __init hugetlb_cma_reserve(int order) reserved = 0; for_each_node_state(nid, N_ONLINE) { int res; - char name[20]; + char name[CMA_MAX_NAME]; size = min(per_node, hugetlb_cma_size - reserved); size = round_up(size, PAGE_SIZE << order); - snprintf(name, 20, "hugetlb%d", nid); + snprintf(name, sizeof(name), "hugetlb%d", nid); res = cma_declare_contiguous_nid(0, size, 0, PAGE_SIZE << order, 0, false, name, &hugetlb_cma[nid], nid); -- 2.27.0