Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp224611pxb; Tue, 31 Aug 2021 19:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4QA6SX29dBG3jOPhfdwxz9au3qtgKceYIcYIyQ80H9nSJaNfql2KHTGycGMI/0nYa/SUu X-Received: by 2002:a5d:91c2:: with SMTP id k2mr24982460ior.117.1630464735729; Tue, 31 Aug 2021 19:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630464735; cv=none; d=google.com; s=arc-20160816; b=ljqsLvbG2SLXzA72Vu4xVsCmKY1v++t77AQV1ECtE2SRbvFQE99naQR26nkTytT68u 5XzRPT44MK+FUUicBwqxjjT1fUJ90ogzygjfk6qtRP06S/a8eekE8zKY6fzVjsl6q4Zh e5HWFH8sW0EU6KulNctZqJCi6lusCia1KkuDEuR03RG3UsAehjmn/IHClVRQAeqQWjlK 9AVLH0JUdPNg/2Nt7cIxnrdPbW7j7O96A1UsFRA4ABlrVikWMvQ9Cyy5gYPCzV5p23mB dPk7bJ7MI3pAzJQgZMqjOrwfmQMatXc1FRPvXKAKpQjhsou9lnKVqhvahIGP0RoibFUW tTpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=t+Zv6WF93nIE2euNIAkdHt7MR9hd9N8epvZ05rGcOHg=; b=yxla3MtzEEZ2ZU5OG91RfU/CTT8qCx/q0fDhLfR3MOCgzSntp3vrZ8qYMJDaRvoocw WlcTor8tCQ2eZSUndR21J2nSomRI/hzw5ORYQxi4dE2pvSVxm5ui2emkv87vfzs5XHie xirJnMx35b0Qj0XgPawmQCoRTHWAmIOrKQYEQs8Jh/5lw7LoIujtu9onRdLnCRr4qLBZ ElWwhUJvcS9PqpfZu9L6a/YvNOe7OZKGHMZXhijs3vLlMi/16/0yHSvk03lvpNKbcUBz aP7BbrAto+eZdMKxRqxC3wy6KhED/QWr56K5Lu82tJp1NXbp63P2a8fZi0OJMMrSrEV5 /3gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si17371932iom.0.2021.08.31.19.52.03; Tue, 31 Aug 2021 19:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241740AbhIACjL (ORCPT + 99 others); Tue, 31 Aug 2021 22:39:11 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:8992 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241726AbhIACjK (ORCPT ); Tue, 31 Aug 2021 22:39:10 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GzpB32SpXzYwWb; Wed, 1 Sep 2021 10:37:31 +0800 (CST) Received: from dggpemm000001.china.huawei.com (7.185.36.245) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 1 Sep 2021 10:38:05 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm000001.china.huawei.com (7.185.36.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 1 Sep 2021 10:38:05 +0800 From: Tong Tiangen To: Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou , CC: , Subject: [PATCH -next v3 3/3] riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable Date: Wed, 1 Sep 2021 02:46:21 +0000 Message-ID: <20210901024621.2528797-4-tongtiangen@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20210901024621.2528797-1-tongtiangen@huawei.com> References: <20210901024621.2528797-1-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm000001.china.huawei.com (7.185.36.245) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org riscv architectures relying on mmap_sem for write in their arch_setup_additional_pages. If the waiting task gets killed by the oom killer it would block oom_reaper from asynchronous address space reclaim and reduce the chances of timely OOM resolving. Wait for the lock in the killable mode and return with EINTR if the task got killed while waiting. Signed-off-by: Tong Tiangen --- arch/riscv/kernel/vdso.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c index e7bd92d8749b..b70956d80408 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c @@ -77,7 +77,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, vdso_len = (vdso_pages + VVAR_NR_PAGES) << PAGE_SHIFT; - mmap_write_lock(mm); + if (mmap_write_lock_killable(mm)) + return -EINTR; + vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0); if (IS_ERR_VALUE(vdso_base)) { ret = vdso_base; -- 2.18.0.huawei.25