From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35544C4332F for ; Fri, 15 Dec 2023 05:52:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A0476B064D; Fri, 15 Dec 2023 00:52:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E0766B064E; Fri, 15 Dec 2023 00:52:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22F646B064F; Fri, 15 Dec 2023 00:52:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0B29F6B064D for ; Fri, 15 Dec 2023 00:52:46 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CC49E1604C2 for ; Fri, 15 Dec 2023 05:52:45 +0000 (UTC) X-FDA: 81567983490.25.BC52FC9 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf30.hostedemail.com (Postfix) with ESMTP id 94AA38001A for ; Fri, 15 Dec 2023 05:52:42 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="os IOs18"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf30.hostedemail.com: domain of quic_aiquny@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_aiquny@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702619562; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WwhbnCJ/fvj1pBHTsPcikQpwh3p9fizJJVTCR0bzuCo=; b=Sr68dnqhihP3bbIQx1JxxOpPSArnC662UUexSrqYTYjM3Q8Mk1Ze5C4BCyJ7xfhN7CvBlh zsKRQIlWAGe6gdehsacyH5afbynpsychQtL9ynfsYFB2X69xtjlqvyZbSB1uMQZFGFK8XU n2dvokVzLOt5be8SSMnH5Zv2l4w3DXI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="os IOs18"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf30.hostedemail.com: domain of quic_aiquny@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_aiquny@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702619562; a=rsa-sha256; cv=none; b=fZrmojpoQz8P4xsf05+yvfODcwc4tY5twW4CRiGG67L7xUAuewekhRH0+V3xkzC8MiiPTX ivl5TOrxbiWoNZADlJnV4IZWP3hPAqqut5F70thr8EYYjX2JrGeRFO4dRYlA2Nm+c2KxJH K793lzmsAkMZjO2JX2SR63TTW59I4Hw= 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 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-Originating-IP: [10.80.80.8] 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 X-Rspamd-Queue-Id: 94AA38001A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bxy31a9qpy5yqpx1cuuwp8ummbzt343i X-HE-Tag: 1702619562-308623 X-HE-Meta: U2FsdGVkX1/3qK8qMltSApaTcYaIxSCIIpaxZRZ4nT2OmbtBCnfDNYAN8UPNr5c6tNJ7T3KaRAmSvzwp+y5T8ni8k2XZaC6It6tooGpSZSsjztPmcHKTJqGcPKe800UnF0pE5cjQvij7mYPrQul7x6nn/K+4Tme9KLUgpOrpDY+C//HCu7W/GGcLN1HR+dw+Eqee3egLmtTEzrJtRrjOH8GK5jiTFNDIrJWuK6AOAl6KubMwAcexih2CoY0wGRw9en4UogsdvbeEDM3Z7g83R9AsqhrU4naPgKNS2BVeBuSgV2UX0CzcvKUJ9chZ0HUzf30XJ2mKuW2XRj+pwxXIG5RiWyMPU1NO3l98pl6rcgvsv0HSjRZYQQM90zdMVeI7PvrKadasc5VlesVdBKrE4t4nFUOuHgVsXER1gYMlXtV5xFzBbFbPrSdO1b6AekAggrKVMYGhQLKAeGLaxxfEaiuIq9JNtgeg9JOsqXu5B6KyUxOX5uDIYKovUc6+DKn6CBTcKKz+QQPBvPfVQ1L8doKmNpgTLeVvB1zVXRh7LLmI+X79ccMJ4nHUVYfTg8Dh5oysQCjefJwAtwHPdRjIhAcPWPhNvN4BWfQq8OvkE8NBINtMVvsdpFi4AbI8vB1fTqbWiH8UBle7/uYz+veo+RVWAT7XAqJTJsbDdF0pj4taDT67XY9r1Dzk8iiZKTnCy6Aj/5mYCA/zb7Z+mmTtZEpc3Z0ZjCncZlFYzbKFRcbu7JGAP/6A+QWodnX+TnBO+MU0Eugh3QdEP78F4S1UAFHZCokMQbnG7z9y1LlApJWy5gtp8VXk45wSxKqY+Jpg7SCdjGAzE5YIww6cB9Bf9jI7L24CITFUD4uJ8dWJsw/Xukw+MCFF3XDxg4pSlA5WuDiESfl6krPtPhcJCqb1U4jtJvhUIwDog8UmMGCS44Q0t+yWW2mHI2geSkWr85gMi3WdbNNWjQwvRx1So20 G+E3XC7u ILLvxV2SGO9s1QugUatgJ5ASi/zlH11BIcACXCd4Gc4dxiMseSRVmvorrfy4t7N28HY+pphEh6Yeemf+KlrbLlAWihCVAnLXmrhHp4LbPPLgR3ztZzBVmIkoIjyDDAqu9F5Xh0dkDsd5kzjz3hrq0+4NIPB6xnIpOsbpF51uLpA2RYhb9OApZlm4xttfwi2+AL0KaN6FoEf6P7LtUn+h1earnmtBg0YUv5oc9cyNoVWRh0teyu7vTfkdkXfgn7f/ePFe/hR6CoMYEpgYHfqpPSbXHZMTvBjzTDlNySjvoffCALex4W77Fj1LIfLEATLxTkRc1zzwbzGNC+fvaoCGYPLDrU8+XU8nMGLJIhypiL8DTKfTjJQ6k/HWEuhDGHKrpG0o98W07+CeskFI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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