From patchwork Tue Jun 25 02:23:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Qi X-Patchwork-Id: 13710451 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 1193EC3064D for ; Tue, 25 Jun 2024 02:24:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3691E6B032E; Mon, 24 Jun 2024 22:24:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 318856B032F; Mon, 24 Jun 2024 22:24:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E0956B0330; Mon, 24 Jun 2024 22:24:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F2DC36B032E for ; Mon, 24 Jun 2024 22:24:03 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8F9B88141D for ; Tue, 25 Jun 2024 02:24:03 +0000 (UTC) X-FDA: 82267815966.29.3534CB0 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf10.hostedemail.com (Postfix) with ESMTP id 01FAEC000C for ; Tue, 25 Jun 2024 02:24:00 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=d60m+Ox8; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of qirui.001@bytedance.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=qirui.001@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719282226; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=qzm1hduKRRbAxkUcBnmHKI4fBaYnqgHeK2tEbBYc8Gc=; b=P/s/Z6XtQOHsQlQFTQl3lDHgXDmjB6aXt0lgndC9PdOEZKP50bkfSmrENWnacRFaCkZ65C +vdVzBd0LCjy76QxuqzSIam4JbnghsqWNRGhxcC6+A1wX9MqeL8WP+6tosDZvoNL6JUMuI Ru2G1mZgjXUqUahFB2XidL2uyPEFt34= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719282226; a=rsa-sha256; cv=none; b=Pt6rJHbbyGhe1a6d0hmNjhs227fJu6v6Hiu2V3cq5B6+J/2/KhIBZAMA/qLvZ2WaP0lUPg DfjFb8yNZ51FM0uHEXoKCFyojtG3K16a2yUYr5q+Xlg5/jeZuZEKzgvvQcXoUfXI1yclGc VWDO4rJcn6yQRDWQwiWjslGNsjIJGCM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=d60m+Ox8; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of qirui.001@bytedance.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=qirui.001@bytedance.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fa0f143b85so18495135ad.3 for ; Mon, 24 Jun 2024 19:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1719282239; x=1719887039; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qzm1hduKRRbAxkUcBnmHKI4fBaYnqgHeK2tEbBYc8Gc=; b=d60m+Ox8ZnwxsqPwVGmrznDqbvBdGPFyZS5NvMOsFOHIz3gDV70ymIjy4eroT5BDAB e01TjTlFjLM3uFXdUTCY9/AXbrNq5kxcRpIHTSQP7rMaAnLVdnELN5ntoMv+GM1CEwF3 +jc85QLXlnegV3lSnQaaXGVOHMuwRSbnGF5FV3bKNlVG1XsMq5QQKkWESP1Eh0b7fSGE sSGkKrzn7w8AlTV588f1iMJdSBUoxZsmTgEX5LxwLuojEKD44nF/IWN8+NQNzLBxfowx WZoVPH5R0Eq6rF1kpMpsp7IHWWlr9pUhXbqrZ0aa2f99ziQx0MV1fVxiipp7c7I7g5Ho UsdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719282239; x=1719887039; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qzm1hduKRRbAxkUcBnmHKI4fBaYnqgHeK2tEbBYc8Gc=; b=NqVYKOhNWqrVJeGEp/mGHM18RcdPA5EPFyoOoTgKDNDAw0KRgey9/ByoWwWLDB5rx7 v3JRTbW8BRGBMygnpqq7l7U+ZzbaUeNk7mGHrXSp6SxoAUf3Y8TELvM24GtWMARJP5qn tH80nAq78KTQdQU4t33+ufR6sc05/mhiOvaumcUcx9hjftNyVFIBvWepJ28Po125MfPU FNrzaZIJMMB+mtqjQKgh/7gCfOC0kUIpcZ+77knllVJIX5w3zI0dsVM3MtczsVS/51x8 +eVi+Ldn0UuRu+KD5+wyCDMKzEOmXj1XKMwYBR42rgWPD3fEsOcYwTrQDHba3EFfHcqH 50DA== X-Gm-Message-State: AOJu0YwLyu1kFAmw3IQ7xVHFnZN0+O2WjwTgVyryKwyGgxNcfm5iIVNi 8gjhwjG3aHPsc0W6Wt87Utk7UP0bHc4ShcxIZATt/sOrlwEb50k19X6yqOcSqfs= X-Google-Smtp-Source: AGHT+IGsqb57dVxWL/Ml4r5D/R2RFk9sxDrqW6p21LQLMaQEG1XbIgWVnE+aoAVQ4+UABxFzuR4CCw== X-Received: by 2002:a17:902:d50b:b0:1f6:dfbc:7f1c with SMTP id d9443c01a7336-1fa23ee51fcmr68860485ad.35.1719282239556; Mon, 24 Jun 2024 19:23:59 -0700 (PDT) Received: from L4CR4519N7.bytedance.net ([203.208.189.12]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9eb3d8bd8sm69386525ad.209.2024.06.24.19.23.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 19:23:59 -0700 (PDT) From: Rui Qi X-Google-Original-From: Rui Qi To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Rui Qi Subject: [PATCH] mm/memory-failure: allow memory allocation from emergency reserves Date: Tue, 25 Jun 2024 10:23:42 +0800 Message-Id: <20240625022342.6158-1-qirui.001@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 01FAEC000C X-Stat-Signature: h9gjtzjcx6tpq8cdea9nff31fw8nu71k X-Rspam-User: X-HE-Tag: 1719282240-336506 X-HE-Meta: U2FsdGVkX18rADoovitkgKDFmZGdmEwPeWJM2sju2i05UpVPsHejSK98bOvVYIXynElxL2t9anPFag7YolP2EJRLzij05ApUnTQBuDGc83zaa2JX/fA7BnFbmIQZHl7akpXBepCkyswd3TWgFr+rbw4JkLhbR8n1sGDel8bk8OxWbXQ6YcCK5aGQnWSjPH2w7FmdDXWAqe58OgqfTUzKo4cEUAPjmpWiF1WLWW6zUtzs02tYAglHt2dS5dIY7apSex8wB2jcz3IPf99FgRvowaGDVgnyfE/rkp8jq4Nl4XyTBMYEhux7lmTRm3lRKkDlzrW1zYeIWYzGKPTQG82y/32EBA2UaBHgABG0MLYnPfc9xkHAOo/pWa/zrmxjcnGhwCdaU691OQcEXcQvLQaGk/sj2Sa1HjArALcnUqtJ7yK8V7lQwJHoRX1Usl7s5sYtflq2RvibtEl0N3RZd2RDHJ+RrQ/vn9EmRWyG7k37rh2MBcieuvwcMY/lcNRNA1eiLLdsTFiyHlHrg9uBQX80hNAd7YaAf1gmj7V1qG2FHAyWMNQ46fyyAbxR/zCc/8+13YBg+LkjDORwMCEJhiS4vCDGRtRzXHZbKhLSm1RZLB5B6yrI+ta/hyh7jowNM02YgTEGi3bcMFyyJm1Q2UqhskOzLSij2AyIV9h5MPBhfd+8d2ZI6kRkaC5wohhWd5PymzhRmlkmn3GOzArQ/U4Pbl26NdyD2uXiUws0QKJTG4hXI//xIVauT1HRyBFixJqDBwdrctQP4sGBAYmMgFAZslMv7XH+iSS6PPEGrDJX7henMQ5DHNQQ5aMyEu5Q7ciU+JkbpxUBZ9ae35BiYkYl4hHOLaWfJ1c1pm/ZEe6+yVk4+DUVh24gpuynOeinPWF9K5xF9xrfGKNThpy43I20iuapyCfIbPlFTswypKkFItshMjwP//Mt+LxpEF8w1T8JQR3gOkLmYQb679JRWu1 oAgG2LUJ kWluASw15r8U4uLz2S7CnJ7qCRyjvdATq9ReX5pUikHJ4DoIMn+nuu1zkr3D5FozzRjMhvrazRERWYivK8/bSl5sK6VnTq52aAmTfHMuX079cQ6bA0isceXKkekV2yPhoYkHpZnBEtFAqkBStccpgzjmaz2vpuel1hFv8x/ZuTmYK8h4LuyfmiPx5MyILDX7FnKgKXncEnmtakpmTiAhZjF2faLsiSGxrgqt967BjQdJTQsOsynHrdUV3DMlpHZbTgy2JcBzdFZ95vW3ifB73EaSN6EwDJHT7A7+/Dxzm7Cc6X3SQRb+Au8BdP+lsDTLrkCKkIC5AJtuOlfqrVpM2z4c96TbBtqtHl7NMJeKrOCktU4FcRv3KcdB6wZRY8+quGBkzDsu/OZMaJOo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000257, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Rui Qi we hope that memory errors can be successfully handled quickly, using __GFP_MEMALLOC can help us improve the success rate of processing under memory pressure, because to_kill struct is freed very quickly, so using __GFP_MEMALLOC will not exacerbate memory pressure for a long time, and more memory will be freed after killed task exiting, which will also reduce memory pressure. Signed-off-by: Rui Qi --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 05818d09b4eb..0608383f927a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -451,7 +451,7 @@ static void __add_to_kill(struct task_struct *tsk, struct page *p, { struct to_kill *tk; - tk = kmalloc(sizeof(struct to_kill), GFP_ATOMIC); + tk = kmalloc(sizeof(struct to_kill), GFP_ATOMIC | __GFP_MEMALLOC); if (!tk) { pr_err("Out of memory while machine check handling\n"); return; @@ -1931,7 +1931,7 @@ static int folio_set_hugetlb_hwpoison(struct folio *folio, struct page *page) return -EHWPOISON; } - raw_hwp = kmalloc(sizeof(struct raw_hwp_page), GFP_ATOMIC); + raw_hwp = kmalloc(sizeof(struct raw_hwp_page), GFP_ATOMIC | __GFP_MEMALLOC); if (raw_hwp) { raw_hwp->page = page; llist_add(&raw_hwp->node, head);