Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp198237pxb; Wed, 18 Aug 2021 19:58:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd1YL1ZouRRPlQiG1RmomovK0VFUyXFhvLrQAGCvH7RJH7vxDcR9ba5NLVeiWZRaYJbmyG X-Received: by 2002:a05:6e02:4c3:: with SMTP id f3mr8387751ils.248.1629341929335; Wed, 18 Aug 2021 19:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629341929; cv=none; d=google.com; s=arc-20160816; b=ZB4sRGzFvlAlh57jB2lHnbYojdVljsDPw1WzWg1ihbENgS61SVKSnYzHQtVqPtxDSm 2LBF5fQ7DDrPFyka8BQoZSO6nBoNfXesX43Yk/30hWkIc3qAXYpJtsfh/s2xP9B8N4yJ XPeFVU+L5kx3gngd30PTY4h90I+Yah2VcZZRF2oeEuj9gTGqSZEb27DevIlIiqJI+gxD zqkI2ELeQ0x3ZO2p6E18wWIOuRyHfaKO87ev29hCNHBVc2RW0QFFDODHURIatCPqztWZ e3vUHkCBnl84kBN8ZAYKgj/MXeqDQ5Zy9SIvpObEx2NRWZrrC8ElnefRQP5ZTzUSoNDJ KEdA== 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=jRoJhvct8Lvzj2Mhg/Yavrc3yFQdHG5OoNvxUqdAmdc=; b=oGjikAWqKHjJlqioLqmmde48U3NVkrsl88sigarU1cmvYvZmG3pXIMMh/WPG7qU3fZ nP+fuzT1XiOlSIV7Yx3GsYoYWaDKCdvgXpgTy2fE6Va7V/9XzIbVEWZyjYB+e/v1jp3l gFeF8prmsNdFw53DnZJlCdxC98TQfYloxnHbyXlhs9MVArn9pzlEYq3O2j5xYtulUD3t ZkBPlCB58yGEfyb0w/Artu65s55LlZQUxfwwyTeIuRNeKVDQHVaRQsgu016TTx116uqC xx1LXG6Euty6MzHEdwoutMe9aDOYlTEAOIQKpbUCFm9VUAhMrLrFswjiw1A4SKcPmZaj /wpw== 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 h25si1624285ioj.39.2021.08.18.19.58.38; Wed, 18 Aug 2021 19:58:49 -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 S235806AbhHSC6a (ORCPT + 99 others); Wed, 18 Aug 2021 22:58:30 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:13444 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235679AbhHSC61 (ORCPT ); Wed, 18 Aug 2021 22:58:27 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Gqq993m5vzdc7k; Thu, 19 Aug 2021 10:54:05 +0800 (CST) Received: from dggpemm000001.china.huawei.com (7.185.36.245) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 19 Aug 2021 10:57:50 +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.2176.2; Thu, 19 Aug 2021 10:57:49 +0800 From: Tong Tiangen To: Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou CC: , , "Tong Tiangen" Subject: [PATCH -next 2/2] riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable Date: Thu, 19 Aug 2021 03:06:50 +0000 Message-ID: <20210819030650.716478-3-tongtiangen@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20210819030650.716478-1-tongtiangen@huawei.com> References: <20210819030650.716478-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 5fecd5529eff..54629c11c639 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c @@ -73,7 +73,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