Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4672578rwe; Tue, 30 Aug 2022 14:50:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR70xjR/0h87yyMUlHiGf6u066gC3xGtWA3GoL3HGfv62qn9mTeLv01q3xOHWdaOYZ2iqEVF X-Received: by 2002:a17:906:9c82:b0:6df:c5f0:d456 with SMTP id fj2-20020a1709069c8200b006dfc5f0d456mr18908940ejc.287.1661896206493; Tue, 30 Aug 2022 14:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661896206; cv=none; d=google.com; s=arc-20160816; b=F2VRLkNXvv38GAok13MS+IWETJ4noHeIeTTUoY3QPgYmGVedVsdssO4jWxKQ84QSMJ 2v+7G4+6yT/XJn4Qkv4iEJF7Z/oWqOGb2LX3BlgQXGjQ6IGqTzPVNQ5ll/i+kjE5Ixqh N89TvHvtP85RG7W0XD92DMzy9V6sMqlSe4ilb1pEh72d8sSYAI3r3RzdY0j0X3UX8tR9 ny0kg9yHp3jpdgkjTJBSmfWEmUbPwT4stf1W5GKkads7KXmZTzVrUhVOssHZMaYm/Yta cvjeTU2Jw8ZABy5+lXTE43hS72Z+/ySfD1ymjhRZSqN5BfJXF+JPRnWlr5Begzai9zq3 GWzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=gEntBcioFa4vIQn/7iA8HQjRG1WVj7ZPRzij+NdsypQ=; b=h5xkfiK6kNl0adddudUbSfhcc+gezrHSKaGgFNNPoZzSMJM1eHMfZ7b75kLIxoAY4c cK6BWDgGz8K599/Xt3efDUcmEBlz9SwMQ1PI3mx9r9o1g3IlcXoVEotjvd+ye5Zw05zm DQ2+rA5wqx8LlRhj+CnV8jStZb/a1yHKyKMp771/LtFjH8uvGu8VuWfrcQjzNfMVp3Y7 kzzfDFTqwNG6u78EGzS+DIluk8qBRzoSuq0sWe8QQeykBNGlsDjwS9v4skMdI8011mRo TlmGl5DyNJLC2fDDhVGSr3wai/h2hEKhbCv7t6Yv5wGabPhSMfhAXKyBinQEeINvy8tX RzKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=eTXF6nsi; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a50ec84000000b00448b9cc50dcsi2356727edr.534.2022.08.30.14.49.42; Tue, 30 Aug 2022 14:50:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=eTXF6nsi; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbiH3Vsy (ORCPT + 99 others); Tue, 30 Aug 2022 17:48:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231768AbiH3Vsp (ORCPT ); Tue, 30 Aug 2022 17:48:45 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B9378E477 for ; Tue, 30 Aug 2022 14:48:45 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27ULVM7G006898; Tue, 30 Aug 2022 21:48:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2022-7-12; bh=gEntBcioFa4vIQn/7iA8HQjRG1WVj7ZPRzij+NdsypQ=; b=eTXF6nsi6QfkFKb/PqnCqLsUoE+Lemi0y8szpAGDqnPtA8axwBg0iJsmuZmBUZWf1yso pLisXmXLLpMcNRhomm9Fa9XRdu5G8F6U4Vsj7OB0b4CJ9StdPTpOaT14tu3oG/eoiFW/ fc3xdNBGsvcywUsUd2Yy8d1yoO3t9hqssTvCrQLil/g3o+exuTbaqIOUyllJu+UU9Mmq nrpf57++RrFJpqL6ACyXN6X1KpCH0W1VAizpWyyQdu/GTD/+GefdJqrjduvVC1sh1hjP L6rg/jRq9dV8lhN8j1tacoPfbW2y1euhLgPVqr00tb+EjQTzpZ4wRoO8stAm1bh9uvAj 4g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3j7btt7nac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Aug 2022 21:48:40 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 27ULfeVR008039; Tue, 30 Aug 2022 21:48:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3j79qapt96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Aug 2022 21:48:38 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27ULmcEJ028504; Tue, 30 Aug 2022 21:48:38 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3j79qapt8q-1; Tue, 30 Aug 2022 21:48:38 +0000 From: Dai Ngo To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v4 0/2] NFSD: memory shrinker for NFSv4 clients Date: Tue, 30 Aug 2022 14:48:31 -0700 Message-Id: <1661896113-8013-1-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-30_12,2022-08-30_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 mlxlogscore=934 adultscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208300097 X-Proofpoint-ORIG-GUID: 1rcaSeyNX9q_qKQlIlBRvRlyJDhCnWNx X-Proofpoint-GUID: 1rcaSeyNX9q_qKQlIlBRvRlyJDhCnWNx X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This patch series implements the memory shrinker for NFSv4 clients to react to system low memory condition. The memory shrinker's count callback is used to trigger the laundromat. The actual work of destroying the expired clients is done by the laundromat itself. We can not destroying the expired clients on the memory shrinler's scan callback context to avoid possible deadlock. By destroying the expired clients, all states associated with these clients are also released. v2: . fix kernel test robot errors in nfsd.h when CONFIG_NFSD_V4 not defined. v3: . add mod_delayed_work in nfsd_courtesy_client_scan to kick start the laundromat. v4: . replace the use of xchg() with vanilla '=' in patch 1. --- Dai Ngo (2): NFSD: keep track of the number of courtesy clients in the system NFSD: add shrinker to reap courtesy clients on low memory condition fs/nfsd/netns.h | 5 ++++ fs/nfsd/nfs4state.c | 65 ++++++++++++++++++++++++++++++++++++++++++++---- fs/nfsd/nfsctl.c | 6 +++-- fs/nfsd/nfsd.h | 9 +++++-- 4 files changed, 76 insertions(+), 9 deletions(-)