From patchwork Tue Aug 16 13:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12944893 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 8784CC2BB41 for ; Tue, 16 Aug 2022 13:06:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76A9A8D0003; Tue, 16 Aug 2022 09:06:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 762058D0005; Tue, 16 Aug 2022 09:06:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DAB48D0003; Tue, 16 Aug 2022 09:06:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4ECB98D0001 for ; Tue, 16 Aug 2022 09:06:23 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2637D41015 for ; Tue, 16 Aug 2022 13:06:23 +0000 (UTC) X-FDA: 79805479446.21.0476E45 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf02.hostedemail.com (Postfix) with ESMTP id 4AAD1801DA for ; Tue, 16 Aug 2022 13:06:22 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M6WZ02KypzmVX4; Tue, 16 Aug 2022 21:04:08 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 16 Aug 2022 21:06:18 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 3/6] mm/hugetlb: fix missing call to restore_reserve_on_error() Date: Tue, 16 Aug 2022 21:05:50 +0800 Message-ID: <20220816130553.31406-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220816130553.31406-1-linmiaohe@huawei.com> References: <20220816130553.31406-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660655182; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oil/VJ5gE0/7sZGswETNnt5928NlpMbTKaEs4rAPiG4=; b=Nc360DR2HaKk4Rerh9ntzjLekQmuYFSRG/iT7C0bz6l/XNT2T5xsqeyI0U7jj74o4TFkxC INET65IkkE3cna8u0QQiBQ/SbgWC+c40tNWpS9c1vTW7LIIoK12XtmOCAMaHt0Q0k6isZW GOShRZSUynVRtSK0hqwXYH8CDT6vNXE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660655182; a=rsa-sha256; cv=none; b=nTTFUkKR4/qHUYXPB3I0x/wppY/1fV2sQIBUcUb/ogyzHWKtYJIlKpXAIBipoYA9D5rgSG 1LYMT4jIZoaF1k+/BVdFUwhsrhtLaqu7aVHk7Fe1IWsK/Nu9raQuHD3jnKi8fdeOGIRJhs YUxs6Bfy2RnYvAtAMUiysgWCuw7vP3I= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4AAD1801DA X-Rspam-User: Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: 5cuoihw1zgcmbauuyzido63h8awnns83 X-HE-Tag: 1660655182-221696 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When huge_add_to_page_cache() fails, the page is freed directly without calling restore_reserve_on_error() to restore reserve for newly allocated pages not in page cache. Fix this by calling restore_reserve_on_error() when huge_add_to_page_cache fails. Signed-off-by: Miaohe Lin --- mm/hugetlb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ff991e5bdf1f..b69d7808f457 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5603,6 +5603,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, if (vma->vm_flags & VM_MAYSHARE) { int err = huge_add_to_page_cache(page, mapping, idx); if (err) { + restore_reserve_on_error(h, vma, haddr, page); put_page(page); if (err == -EEXIST) goto retry;