Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp207563rdd; Tue, 9 Jan 2024 01:15:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEc9YknVSQbU5ivZlOeF2zOfE7DRDKOIK2YCnhzpZiHf0sZ5mZZWCU0YVJTSGnR8bhdFT1C X-Received: by 2002:a17:903:24f:b0:1d4:75c8:6d2d with SMTP id j15-20020a170903024f00b001d475c86d2dmr6157786plh.49.1704791755958; Tue, 09 Jan 2024 01:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704791755; cv=none; d=google.com; s=arc-20160816; b=Al4dsINlNKI3KZNC2sYqa7EvcUoaEjxGSOouGaYpavOcmsJOSTt3g5/lgQuE5i1/T1 LWMd4iSNgI+9TsGjxjADbPa11NlwC3qhfLKrlpkl8lNa9vuA9aP9ZKLMpel44C3Q8wrJ iZ3vgbwYH9FB474KJxVAh1MQWmhKZi8l1QoCbOsQrigeU+B3k45v+BnvTyzKff5dpgVP yllekN6wRZ1TaBYB09+kVZ+iz8v4fwVIIQSrdvCxanMBbCgq3aZNH/VaMlHnUA6b4ZI0 u3YI9uk+uXEGEiZa9F9klxltZKhwYH+tZeF79cHnfdytO1k4AG4Wp/D6AdTpqi/uAh4D ibDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=+xyrwDFS099oTZr80eG8tqlbdegvI+EmzfeYorlmT8s=; fh=DIJ01Ae6+3TNHKEdae74IbciJB1Kgg4ryiuG3K+I8lE=; b=U+HrYlPR4KWvS6PivYdbs278chfLFBLfJOgJzIX9by/5uMYOyNrVv5fGvfaW764xKL xpKY69eyJe8oJFWdjC/mKa/SG5oVZE0T8Koy8dgHgkLaBG4JZYLXeIjm2UaQ+TUrfzcT +cC30IwFVbbhEZmgXWcmFFYqmgK81GOSRFajRLHL7aGCjfDgQfVmiEwjOUZZJJk7SbUC CzJulRu1COA2yCrLu6RQQpggPknsWKJLIiO2ynuVn+3l74DU9b5HfLuzR3huE09T7oQW eGdLTUL6+ufEOkRb1IAkx2JyFq3xqohJfagv5ufclUbi/8AJxzqD7OivzHvyo3MKwlpQ mAFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=LwPgBZ8F; spf=pass (google.com: domain of linux-kernel+bounces-20638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jw20-20020a170903279400b001d05ec3be0bsi1227168plb.130.2024.01.09.01.15.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:15:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=LwPgBZ8F; spf=pass (google.com: domain of linux-kernel+bounces-20638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.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 4D1562882D3 for ; Tue, 9 Jan 2024 09:15:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34E8D2E85E; Tue, 9 Jan 2024 09:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="LwPgBZ8F" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 9D70629CF1 for ; Tue, 9 Jan 2024 09:15:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4099ExJF002379; Tue, 9 Jan 2024 09:15:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=+xyrwDFS099oTZr80eG8tqlbdegvI+EmzfeYorlmT8s=; b=LwPgBZ8FNFDr95rT4pYF6Jb9Nqwk0ExICiU9LTw94K2MnYwAKMqPES5Gl+aCvrBTSYct avy/AXVkQTv0Ai57iyzSAjwoPBcQAVebzTw5Vd2P5MifynPKWR+VLclqSDUZFofatJCy e2g0siJ4Nc4iaKZmqnZA+PP2ti9ocd/97qw+vHJzmmGQIHOQXMsJP2X9bL3funAg168J rp1qc9trPCBRXDP9l9xw63G/i6G34XtAXm0wvtxxSJIVx+BC8Rl6QFvWHsizZVuG1cwg 1+GtlU1DxhfifcLdypb8Ae0VryLpdb3HCjc56Ax9XFtcYg+sLvxNqHkoETBCzebA/8Vq eg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vh3bd0020-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Jan 2024 09:15:14 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4098Xsuf006721; Tue, 9 Jan 2024 09:15:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3vfur3f6rt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Jan 2024 09:15:13 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4099FCea007613; Tue, 9 Jan 2024 09:15:13 GMT Received: from jfwang-mac.us.oracle.com (dhcp-10-159-139-172.vpn.oracle.com [10.159.139.172]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3vfur3f6r8-1; Tue, 09 Jan 2024 09:15:12 +0000 From: Jianfeng Wang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jianfeng Wang Subject: [PATCH] mm, oom: Add lru_add_drain() in __oom_reap_task_mm() Date: Tue, 9 Jan 2024 01:15:11 -0800 Message-ID: <20240109091511.8299-1-jianfeng.w.wang@oracle.com> X-Mailer: git-send-email 2.42.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=2024-01-09_03,2024-01-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401090073 X-Proofpoint-ORIG-GUID: 89_hUgsNPu7_jKHX54smR6a95sDi_sq1 X-Proofpoint-GUID: 89_hUgsNPu7_jKHX54smR6a95sDi_sq1 The oom_reaper tries to reclaim additional memory owned by the oom victim. In __oom_reap_task_mm(), it uses mmu_gather for batched page free. After oom_reaper was added, mmu_gather feature introduced CONFIG_MMU_GATHER_NO_GATHER (in 'commit 952a31c9e6fa ("asm-generic/tlb: Introduce CONFIG_HAVE_MMU_GATHER_NO_GATHER=y")', an option to skip batched page free. If set, tlb_batch_pages_flush(), which is responsible for calling lru_add_drain(), is skipped during tlb_finish_mmu(). Without it, pages could still be held by per-cpu fbatches rather than be freed. This fix adds lru_add_drain() prior to mmu_gather. This makes the code consistent with other cases where mmu_gather is used for freeing pages. Signed-off-by: Jianfeng Wang --- mm/oom_kill.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 9e6071fde34a..e2fcf4f062ea 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -537,6 +537,7 @@ static bool __oom_reap_task_mm(struct mm_struct *mm) struct mmu_notifier_range range; struct mmu_gather tlb; + lru_add_drain(); mmu_notifier_range_init(&range, MMU_NOTIFY_UNMAP, 0, mm, vma->vm_start, vma->vm_end); -- 2.42.1