From mboxrd@z Thu Jan 1 00:00:00 1970 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 D8F8E37B3FE for ; Tue, 18 Aug 2026 03:31:21 +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=1787023883; cv=none; b=AM5wLovnDFGn8zugaAtsRnwZZ5gCWIVO9016ygbuvw0OTnwo7/qPQffXW3Zx/RlqIKSBrfi1KQh5SZ99CA7kQbrcW0b/6kCNcvpNdXG8FI4wOCU+lSbCQAS8XSzdQBNsQlczOFjcCZ036aE5nu9ATRJoavq/pn+yxW5AChvzOEM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787023883; c=relaxed/simple; bh=Z3oxHxcTFL5ZtU4TflVlgGNV5nFevMrhFGK6bXSJbkI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XyNXGFH5mCl28s6GUnBElPDIZ2MdadzCD/U3c8/F09o2ERZsuuBZbl2x6eX13vXT/GnpLyI/YVyURNmSTBTxzoPvZA1cI9qjxg0Nn4+jSJ6lsA7mayWY2tzUIkQ7aiQPFlLz2SRMlw5Y03eXgDW4jMYIqW9dhoBHlfLp1ZXR8Dc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=WxE8fowl; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=XMht2s2M; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="WxE8fowl"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="XMht2s2M" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67I28SS02884748 for ; Tue, 18 Aug 2026 03:31:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Z3oxHxcTFL5ZtU4TflVlgGNV5nFevMrhFGK6bXSJbkI=; b=WxE8fowl1MucME53 JfxgfPPtls9KeI83UnUZ9/zfLyrlAGz8+9clyv6w+xA9MbhCLkRCNwLwV529VzDz Uzq+7b4SyIUNuQLNF8jfGe8r9EH/kozFrFHsz9YqxvT+Dop5Ch21zCim0rLImLnP 8zOQwpeltnoR7cKia+AtiyEUg+Dkf1PfElkdKjt1EJt6pPpwvLi0V9KE5uogBlhV 1VLMnpTT/fHXSqNFxeYa+zlUACV619Mw6LY12KxOE9uM55mzbPzQIp4diha4w37t t66fXW3VGPbmjMJzo/hH5WyGlBgacZ5nGvJz8US9TGwifXxCn5MufuztevwovFZR T/yaZw== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g4ebpramq-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 18 Aug 2026 03:31:20 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2d55d8cd938so48235385ad.1 for ; Mon, 17 Aug 2026 20:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787023879; x=1787628679; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Z3oxHxcTFL5ZtU4TflVlgGNV5nFevMrhFGK6bXSJbkI=; b=XMht2s2MTWJkwLmkepxalz9mYLAJT0Y/JszcpbCiJV6A2D7Tb8nZdcC7VfyxjRdrc1 WzNVd2Ip7YvD4ViXV6M7FDIPeovtU2RRzrWDi3gv/v1zfhbtfPVN0rQ95uIcqp1UrL4n +DBaHwMX3BGt+/AqRW4/asmTLDpKhrlxgpbtprgXQb9Se21F+vWs7gY9K6UACBWrd0vw MRCn8PFsIGJ7kZ4XRBjoljpDUQ1u77Z9E52/cWjQzf2eQWAd49ts1dyWbTIhmtQK12zj tCm1z6YCF5YOKH2xenJSqIW3sJq0xuRl5Axvy5pQsHBdsAmlK8/ibBqXFTBY8pNUivY4 6Geg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787023879; x=1787628679; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:subject:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Z3oxHxcTFL5ZtU4TflVlgGNV5nFevMrhFGK6bXSJbkI=; b=l1neYPzkyBZio0h07gCuF4Sn1JWnxlq8/99A+3gxJQipm0/R1f0iXgdXkvHaiMmHkd 9l4C1dcJjAmm3b5bEHctlLLse24PJHE7lAjC2cttaAjLlpnD46STA9vPjzWBogTZfaAC 3HD8b7exUkXkaTSMUvwCHyKFd3UQiP5lBPe/hsDbO6Zw44DwmxZDEE8e5KLhcBk+l2BU R5betu4SlvXWdH1A1rx+tcDXNvhazIlj77BJMWocZYP9uDe8DvnuZo11W0v3BoTSMQIl Eo26ihjfVxTBC4k+ZIXjAzin6KWHLTKdMl+c4mOh3rghVA53VfaWMAmjlBPQXIpTMaV/ +iNg== X-Forwarded-Encrypted: i=1; AHgh+Rpsd1wzbIJgoPFHphb/itY7tNwLUz7/Sp9VbRkEWR12jyHINoEmpkmxtRZjHkoM2vnOP4bilef02JQRWqQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw70+ep/pm+Z+1ui7I6C94d/jbnjYB23bUBWf5aCwguIVVF66yy eAp2rb4/N/H2Bf5gkvyxGpAfd/cR4445ZnGlEHwjJEtavob9atXS0ls4KlaS+K2zyZuo1nX+STf FLu+gYseJTKtJ87X3bUPIbPmSF0zJGCuV1hT08zrCnIq6Xrj0chrslzeK2dL9AK88ESmidPQJMg p3zw== X-Gm-Gg: AR+sD11KNl9dQBfn3vNdmTVdmIKpLY8Ut34HmOv7+wPruujwrXHQTXikhr68oZ7aQWe x7z3lLxFJNkeZD1seoP1hvLSSlcFAOj02FVsZU3sTiKBQw92HjHO72GqVJu1OkLTwISgG0rTL7K aDpKcylq4cE7bzYizuBLaIjcFOq/Kr/kexC4kFgms2wTA/BeBTncOas1p0vWqUcZA7SvJ5K0l7s ySTv7DT/OY0IZx4HLhTffqVXGTMYUn13N8poolhf59C5CuDeEeWhBZU4UHhmKtq85GwUc4wFE74 Gm7e07Ca/3AtlDzRDnLt02sgtaJ+XYff3vW9826oAP68ajYtidexbI6vDMbQzznkz8OUHIaJ3tc UnzWAlpNYTcdOU8juJ6H7s5Q= X-Received: by 2002:a17:902:fd8f:b0:2cc:d6de:d597 with SMTP id d9443c01a7336-2d3b086d3f8mr330636105ad.7.1787023879456; Mon, 17 Aug 2026 20:31:19 -0700 (PDT) X-Received: by 2002:a17:902:fd8f:b0:2cc:d6de:d597 with SMTP id d9443c01a7336-2d3b086d3f8mr330635415ad.7.1787023879042; Mon, 17 Aug 2026 20:31:19 -0700 (PDT) Received: from [10.239.97.207] ([114.94.8.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d5c1e5506asm9210625ad.43.2026.08.17.20.31.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Aug 2026 20:31:18 -0700 (PDT) Message-ID: Date: Tue, 18 Aug 2026 11:31:14 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] tty: n_tty: use kvzalloc/kvfree for line discipline data To: Greg KH Cc: jirislaby@kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, liulzhao@qti.qualcomm.com, cheng.jiang@oss.qualcomm.com, cxin@qti.qualcomm.com References: <20260817135526.386863-1-xin.chen2@oss.qualcomm.com> <2026081706-tricky-slicing-166f@gregkh> From: Xin Chen In-Reply-To: <2026081706-tricky-slicing-166f@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: F6S0UvHwy2M3bo61rnPy5LJTqb2YcMR7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE4MDAyNCBTYWx0ZWRfX7HupKYldzR/I UkZRWUjPYcjpfxM2MO5sqHMBeZcOZn0IfiuA/wmp/b4JitTsaGl/QpqYcdSzRMlDGgZW2AQ06Me cCQTGU6UY9t0RdZkNgs5GQ3P4zqs5YzDOhwu00YRDogVCC8ZUH+XiNfc/JwkJ1sFHTaIJy/QSuZ Co6oqEzTUAshQwO7ldc5IddvJNDDmRadSdvkHx+37eemRSyiAqPW715z8+1I0/f1tWYbhIB0Een qL5J5CimBIBB5rCSZlR1Ti+yTh0qLLTI2q6O7p1p7MlTAinVipYk+Sn1NLAsyF1AwdRNx/Cy+Vh setw+39L3RM82RNH8llO1/Z1imvG5MdlpaaWc0zC7/JHVhfsOcUWaqWGhmAkpiYM2q4+EmtgmYJ +u9k4ZXH5knqsPmNPVoQ7eAkvy4oCoBWz75duU6fZviG3kXe2eYgps6cLXS4L4G1NIOXuOzF92f gTOZglo9g8T0QUCqHZQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwODE4MDAyNCBTYWx0ZWRfX0WGdNPPEgJiz lehBS4mAqnB9IGD3rgJ67suf/9z2/4ceCstu0RF0s/nsO1qAOAFhWj11nPBsEhxUcBrc2jvoPoB hJF0+FPsmUd0JvILZw9nUdooG+aOugQ= X-Authority-Analysis: v=2.4 cv=FsU1OWrq c=1 sm=1 tr=0 ts=6a83d208 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=Uz3yg00KUFJ2y2WijEJ4bw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=70wutVrNsAcyFLlXve8A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-ORIG-GUID: F6S0UvHwy2M3bo61rnPy5LJTqb2YcMR7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-17_04,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608180024 On Mon, Aug 17, 2026, Greg KH wrote: > So you run out of memory?  That feels wrong. Not a full OOM — just a transient exhaustion of order-0 pages caused by repeated vzalloc() calls each draining the buddy order-0 free list. The system recovers quickly, but the damage is already done by then. > Why not just use a specific slab for this one structure if it is so > important that it never run out? kvzalloc() already achieves that: it tries kmalloc() first, which serves the ~10 KB n_tty_data from the kmalloc-16384 slab (an order-2 compound page), leaving the order-0 free list intact. A dedicated slab would add complexity without further benefit. > Why was this using vzalloc() in the first place if it could fail? Historically, ~10 KB was considered too large for kmalloc(), so vzalloc() was used. kvzalloc() is the natural modern replacement: it tries kmalloc() first and falls back to vmalloc() only on failure, which is strictly better. > And if it does fail, doesn't everything work properly, you just need > to handle that failure in userspace correctly, right? Even if the error were surfaced correctly to userspace, there is nothing useful it can do. The actual failure here is that skb_clone() in hci_send_cmd_sync() silently fails due to the depleted order-0 free list, leaving hdev->req_skb NULL. The firmware reply arrives and is processed, but hci_req_cmd_complete() cannot find the completion callback, so the waiter times out with -ETIMEDOUT. From userspace's perspective this looks like a hardware or firmware timeout, not a memory issue. Even if userspace retried BT enable, it would trigger serdev_device_open() again, which calls n_tty_open() again, which calls vzalloc() again — further draining the order-0 free list and making recovery harder. The root fix is to stop consuming order-0 pages unnecessarily in the first place, which is exactly what switching to kvzalloc() achieves. Thanks, Xin Chen