Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6466624rdb; Thu, 14 Dec 2023 21:53:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMCVSYrm/7fsM+JsPuSV2rjDTkuA9RvxDrdYAcKOrJZrkbG2StPHjMKIF9j7kEDOh8LCz2 X-Received: by 2002:a05:6358:787:b0:170:b81b:4a20 with SMTP id n7-20020a056358078700b00170b81b4a20mr12306506rwj.51.1702619588418; Thu, 14 Dec 2023 21:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702619588; cv=none; d=google.com; s=arc-20160816; b=NK/YQZ/uMKXc8ny8uGJ8mZy7VcxGIgVNbQn+smvCzwlKMaGkf47udAXAzoAvbiSISH UyQw682/WX44ETOHQ1NJRZRBPZ2OgNtxYcdFPQGnFQ1WfAkHWwabMrzaEz/UJPdmRDdV HRO1mDWx9GF4Z3or+ovOmlgPOUf3Fprt6bjz/qOJDIl3MudiBXMU3SWZnX4XyvPOapji 5b2nkw3te7D5wUXKOpNwZ4eMK3A/2OOPeykpY1ttYsWWDU/OxA3HXpXb+qzWmNJZSxBB caRFQ+d3sFdAvnV8kb9M1SVhyyIfx7lXS1KECxFiZWDfBbpV3dtgjNud8lh2Wg/A5O48 9HsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=WwhbnCJ/fvj1pBHTsPcikQpwh3p9fizJJVTCR0bzuCo=; fh=wqQ0E3LzcCenjZzLmYH9MKjyR8joBKfGGtvgwSvJP+8=; b=H/6sX7XoMbyLkOHrytqps7u4A7KPCKFn7UUUlQeoTFCCV3gjuDTWouR2YtumnFlnrP UHsnEB8qpyU+v8h//RyT4Q2JQzQ+cK0u96Mw2DTE0Qe6xxgovt9qpi+iJZN1tAq6tgLq I/W2kQtBLnye6vzyEK3dsKZSjLowW221vHsMTFnfD6QNXbkhYewlqYhDajtDKaUGLJUZ aPUmAgm+Vhxxc7SYlInGt1ql6/3F4iVNPBEqJBEIOvXPUUR8DqdQB+HHE36em/A6q3h2 IAQkV6FB4TrIsBtOu+fzX0tKW46I8dvXegDD6RlSSSYqAPWiADw7776iwKJ+QkLApEAP w32A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=osIOs18x; spf=pass (google.com: domain of linux-kernel+bounces-464-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x17-20020a1709027c1100b001cc2c4fdbecsi3730134pll.649.2023.12.14.21.53.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 21:53:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-464-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=osIOs18x; spf=pass (google.com: domain of linux-kernel+bounces-464-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-464-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 116CE28444D for ; Fri, 15 Dec 2023 05:53:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7517C79F3; Fri, 15 Dec 2023 05:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="osIOs18x" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 6C470DDA8; Fri, 15 Dec 2023 05:52:52 +0000 (UTC) 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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BF3tA23030077; Fri, 15 Dec 2023 05:52:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=WwhbnCJ/fvj1pBHTsPcikQpwh3p9fizJJVTCR0bzuCo=; b=os IOs18xp/yBTZqmdQzVbjlJTRbFjICiHbu9cijQ0MNmMnxMm0nE88Ap3eyc222Y/B n1RFlSredGasfpyvHZiA5cRJrQ41j1cGUYTf8N7AcnSFBJZQd5BYVrWmmUZXJpHo OvDCjCWCFF8tqtKb2JdefmfpHEDY4cAtDfrVThmNNPiQHm7pmF6JOaRxOY/Znppe k0yxmOzsADwRB54Nu0VD6lnhZydUlgecvtpb4H6UAruSxXTxfNGwYGi4rueVo0KE Rm6kQqu550Rl2EJZLDN51Kgbuc5GSEgZFEtGs13R0Bay3rmqbxh/0Vhpk8d2dLte xADAHzfUcPaEoElYgAuQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uyp0pb79r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 05:52:25 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BF5qOFd024341 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 05:52:24 GMT Received: from [10.239.132.150] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 14 Dec 2023 21:52:16 -0800 Message-ID: <75de85ae-ebcb-4f86-8cbf-749708cb3668@quicinc.com> Date: Fri, 15 Dec 2023 13:52: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] kernel: Introduce a write lock/unlock wrapper for tasklist_lock Content-Language: en-US To: "Eric W. Biederman" , Matthew Wilcox CC: , , , , , , , , , , , , , , , , References: <20231213101745.4526-1-quic_aiquny@quicinc.com> <87o7eu7ybq.fsf@email.froward.int.ebiederm.org> From: "Aiqun Yu (Maria)" In-Reply-To: <87o7eu7ybq.fsf@email.froward.int.ebiederm.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 9L7uaS1JyabO0j9O4o1SCZxK4G0IVJ0o X-Proofpoint-GUID: 9L7uaS1JyabO0j9O4o1SCZxK4G0IVJ0o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=543 mlxscore=0 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312150034 On 12/14/2023 2:27 AM, Eric W. Biederman wrote: > Matthew Wilcox writes: > >> On Wed, Dec 13, 2023 at 06:17:45PM +0800, Maria Yu wrote: >>> +static inline void write_lock_tasklist_lock(void) >>> +{ >>> + while (1) { >>> + local_irq_disable(); >>> + if (write_trylock(&tasklist_lock)) >>> + break; >>> + local_irq_enable(); >>> + cpu_relax(); >> >> This is a bad implementation though. You don't set the _QW_WAITING flag Any better ideas and suggestions are welcomed. :) >> so readers don't know that there's a pending writer. Also, I've see >> cpu_relax() pessimise CPU behaviour; putting it into a low-power mode >> that takes a while to wake up from. >> >> I think the right way to fix this is to pass a boolean flag to >> queued_write_lock_slowpath() to let it know whether it can re-enable >> interrupts while checking whether _QW_WAITING is set. > > Yes. It seems to make sense to distinguish between write_lock_irq and > write_lock_irqsave and fix this for all of write_lock_irq. > Let me think about this. It seems a possible because there is a special behavior from reader side when in interrupt it will directly get the lock regardless of the pending writer. > Either that or someone can put in the work to start making the > tasklist_lock go away. > > Eric > -- Thx and BRs, Aiqun(Maria) Yu