Message ID | 56154bf4-c1e2-16d5-c6e2-c2dee42d3377@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-35153-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp255607dyi; Tue, 23 Jan 2024 03:06:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkMvVw2m7fuYFMtA8Xc6N8coLGc2NOwDYCsQu+R76UVXaFecyOAZZPSXS8n9irJ+prUNE4 X-Received: by 2002:a05:6214:2a8f:b0:685:fc9f:b5c8 with SMTP id jr15-20020a0562142a8f00b00685fc9fb5c8mr719499qvb.30.1706007992124; Tue, 23 Jan 2024 03:06:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706007992; cv=pass; d=google.com; s=arc-20160816; b=QzG3wdDexRkPgbm8C/b/uBg5wttZ8JQ0+8saqgnFdvYrJBXqdVYuIQxhjxxDpdF3sE 0t4J0qskJ75G+++1B25Sz8MIz7zyrtRpiXweMUiJXvPr/xs1fg8HkqE9r4mQuoj38v/u zDfkEP5LN0zMbYcrxnM0p5cHAQh7o3LsmAXQ6KJ/2WqmFlIdYL8puVJT5dMI3kr7+wdn L5e2k4PuYMHVCT+nK0g6RGmFTDVnrBCzkLZtNlgoOeO2VCgEM+tZ7y14dEuH+pKDtCCh etnNsQfHgZSihdK+tRWPPRpEsBdvOlpR7Ng2v4UTirq5AMy5nCDM+5vJeObC1D9fq4Jf IwcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:subject:cc:to:from:content-language :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=ep+LJJCGCPOiBkIso0GxeydK6txy6MfI/exTM73RNrI=; fh=pJrKBflc+TDprKlj4LHBQz2P0dWCtLUub8FscZ+qQkA=; b=rWxDG3OB4URYOHLWlc3i9r5ymC7hmuI5Bb269oE5+lm9vPiR7AZweg2kbfuEOXksRp xJq2xP5TJMK+KuFtDc/4O3AhScvC+9cMkd2iwyqMn11rJ3HYOBErw68w2xNhTKw53sJe wGHuT8ag79MV3diXWw2Bbw56xfVnBtMEUsGXq4NxvUSgSlc06tskvtfEJS5CIt9HmZBT 2iPuC0XkJ8gMjdWweBmH56cQyebL/NNiwpnC21wc6+dRQklgBSp/LE0+b/oKXLjeroAO Wi32yFEXGHOjsgr5rcwOqfw6cXJYLtoJdmfb5uEPqMFtvt4G2HZM9xsBiH/xmqR5yaA2 3iLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=p6xYMsIK; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-35153-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35153-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o10-20020a05620a228a00b007815767172esi7421087qkh.36.2024.01.23.03.06.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 03:06:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35153-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=p6xYMsIK; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-35153-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35153-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D2F0E1C2225B for <ouuuleilei@gmail.com>; Tue, 23 Jan 2024 11:06:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F14A85DF3D; Tue, 23 Jan 2024 11:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="p6xYMsIK" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C173F5DF13 for <linux-kernel@vger.kernel.org>; Tue, 23 Jan 2024 11:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706007853; cv=none; b=MIyD1SALhaPmIxXoJlXB42pR57/aI58AvJbBegMS+8BSr2ZotMe/ynm1nPwv/KHBaOINUM6x4Sc1QT5mYo4Lw1Is9ZZ79NCiMSwnJq/YFYSOX1MsroZ4ke61qKr937T3mtb622i7KSiN7YmBc4UYyi0fj8xHUY/NQaRXI63KRR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706007853; c=relaxed/simple; bh=2i6lV9/1dpM70IMRlA2HW1ksIVKBRL+Sy8MAykGS0LQ=; h=Message-ID:Date:MIME-Version:From:To:CC:Subject:Content-Type; b=GaH8HASPeCY+8SN/VwUykJHPoA6z4b2sF7Eem2KUI2dUIZZpqDKi5uIZoynynkbscx9r4eOg0dMVM1ojjfBe7NsW2Xo9vr02lneQe9ZQKV3yqODcqgvn2htmZex6+qxp7VrcdnDbtf1cFOprWjicv2inwnWIR8Szbvi88ZHeYvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=p6xYMsIK; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40NAEF0T024765; Tue, 23 Jan 2024 11:03:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:from:to:cc:subject:content-type :content-transfer-encoding; s=qcppdkim1; bh=ep+LJJCGCPOiBkIso0Gx eydK6txy6MfI/exTM73RNrI=; b=p6xYMsIKphvCwTjSyT3TWEty4p2cL3XF3Sr0 /hEKPkGWDBBRBaH9hHvBzE59N1fSoBHv6Dv7Nhsyq9jeai/bk2NSiE4I9rxKiQ1Q Z0GofyBhCLC4nyIcu3LE1ZR4z4KsebRUFFllJ5NcICo48CZ03lqtcDaV6s12lEnH jB0SU7EUXt+wnep2X5O2vXkJ45bU/r9C7KhzGmPy+JcZ5JeL/i2rERtHaMj7tWJz Mw3p8rEp0Rmk0sik/hPuxTYEJ0z39yInShUdas9AEv9YpvSlCDXTPC81BHzvD93V IqIgJ0IBoppuzt9Y4kMaFvHBeSWcW0nYQTj/lmW+sOED39/sKQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vt8140jd0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Jan 2024 11:03:57 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40NB3uKU028388 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Jan 2024 11:03:56 GMT Received: from [10.214.66.119] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 23 Jan 2024 03:03:54 -0800 Message-ID: <56154bf4-c1e2-16d5-c6e2-c2dee42d3377@quicinc.com> Date: Tue, 23 Jan 2024 16:33:51 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US From: Charan Teja Kalla <quic_charante@quicinc.com> To: <Liam.Howlett@oracle.com>, Matthew Wilcox <willy@infradead.org> CC: "linux-mm@kvack.org" <linux-mm@kvack.org>, LKML <linux-kernel@vger.kernel.org> Subject: Purpose of maple_node objects to be its size aligned Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: hCX1sMD41WRuH3wU0PexQVokd9gePt1y X-Proofpoint-ORIG-GUID: hCX1sMD41WRuH3wU0PexQVokd9gePt1y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-23_05,2024-01-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 mlxlogscore=998 clxscore=1011 impostorscore=0 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401230080 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788879036210212136 X-GMAIL-MSGID: 1788879036210212136 |
Series |
Purpose of maple_node objects to be its size aligned
|
|
Commit Message
Charan Teja Kalla
Jan. 23, 2024, 11:03 a.m. UTC
I am just curious about the purpose of maple node slab objects to be its size aligned, but I can understand why they need to be cache aligned. void __init maple_tree_init(void) { maple_node_cache = kmem_cache_create("maple_node", sizeof(struct maple_node), sizeof(struct maple_node),// Alignment of the slab object. SLAB_PANIC, NULL); } Reason for the ask is, when slub debug enabled with option Z, the change [1] makes the total object to be 256 * 3 (=768)bytes. This turns out to be a problem in debug builds where the unreclaimable slab consumption itself is very high thus exerting the memory pressure on the system. maple_node: orginal object size = 256b after slub_debug enabled = 768b If, there is no special requirement, other than just needs to be cache aligned, thinking of the below: [1]d86bd1bece6f ("mm/slub: support left redzone") Thanks, charan
Comments
On Tue, Jan 23, 2024 at 04:33:51PM +0530, Charan Teja Kalla wrote: > I am just curious about the purpose of maple node slab objects to be its > size aligned, but I can understand why they need to be cache aligned. Because we encode various information in the bottom few bits of the maple node pointer. /* * The Maple Tree squeezes various bits in at various points which aren't * necessarily obvious. Usually, this is done by observing that pointers are * N-byte aligned and thus the bottom log_2(N) bits are available for use. We * don't use the high bits of pointers to store additional information because * we don't know what bits are unused on any given architecture. * * Nodes are 256 bytes in size and are also aligned to 256 bytes, giving us 8 * low bits for our own purposes. Nodes are currently of 4 types: * 1. Single pointer (Range is 0-0) * 2. Non-leaf Allocation Range nodes * 3. Non-leaf Range nodes * 4. Leaf Range nodes All nodes consist of a number of node slots, * pivots, and a parent pointer. */ > Reason for the ask is, when slub debug enabled with option Z, the change > [1] makes the total object to be 256 * 3 (=768)bytes. This turns out to > be a problem in debug builds where the unreclaimable slab consumption > itself is very high thus exerting the memory pressure on the system. That seems like a very badly implemented patch. Rather than make all objects left & right redzone, we should simply insert a redzone at the beginning of the slab. ie 0 redzone 256 node 512 redzone 768 node 1024 redzone 1280 node [...] 3072 redzone 3382 node 3584 redzone 3840 wasted space Instead of getting only five nodes per 4kB page, we'd get seven; about a 30% reduction in memory usage. Slab redzoning is not a feature people turn on often, so I'm not surprised nobody's noticed before now.
Thanks Matthew!! On 1/23/2024 6:56 PM, Matthew Wilcox wrote: >> I am just curious about the purpose of maple node slab objects to be its >> size aligned, but I can understand why they need to be cache aligned. > Because we encode various information in the bottom few bits of the > maple node pointer. > > /* > * The Maple Tree squeezes various bits in at various points which aren't > * necessarily obvious. Usually, this is done by observing that pointers are > * N-byte aligned and thus the bottom log_2(N) bits are available for use. We > * don't use the high bits of pointers to store additional information because > * we don't know what bits are unused on any given architecture. > * > * Nodes are 256 bytes in size and are also aligned to 256 bytes, giving us 8 > * low bits for our own purposes. Nodes are currently of 4 types: > * 1. Single pointer (Range is 0-0) > * 2. Non-leaf Allocation Range nodes > * 3. Non-leaf Range nodes > * 4. Leaf Range nodes All nodes consist of a number of node slots, > * pivots, and a parent pointer. > */ > I got it. Looks like I need to revisit the maple tree documentation before asking such questions. > That seems like a very badly implemented patch. Rather than make all > objects left & right redzone, we should simply insert a redzone at > the beginning of the slab. ie > > 0 redzone > 256 node > 512 redzone > 768 node > 1024 redzone > 1280 node > [...] > 3072 redzone > 3382 node > 3584 redzone > 3840 wasted space > This seems to work when only redzone is enabled? I think it will again 768b aligned if any other debug option enabled, say U. It is: (size aligned red zone + maple node + right red zone (size of (void*)) + alloc/free track). My understanding to have both left and right red zone is: /* * Add some empty padding so that __we can catch * overwrites from earlier objects rather than let * tracking information or the free pointer be * corrupted if a user writes before the start * of the object__. */ When all the debug options enabled, the slab object will roughly look like below: Left red zone | object | right red zone | free pointer | alloc/free track | padding > Instead of getting only five nodes per 4kB page, we'd get seven; about > a 30% reduction in memory usage. > > Slab redzoning is not a feature people turn on often, so I'm not > surprised nobody's noticed before now. +Vlastimil. The patch in discussion is d86bd1bece6f ("mm/slub: support left redzone"). Thanks, Charan
--- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6283,8 +6283,8 @@ bool mas_nomem(struct ma_state *mas, gfp_t gfp) void __init maple_tree_init(void) { maple_node_cache = kmem_cache_create("maple_node", - sizeof(struct maple_node), sizeof(struct maple_node), - SLAB_PANIC, NULL); + sizeof(struct maple_node), 0, + SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); }