Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2219225rdg; Sun, 15 Oct 2023 17:45:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHh3GUFAFI6Bw4dl3/1x/1ILHUeVFK3Lwo+yLGRT7sKIqmKX4WAS/fCR8hDvsPmm2uj0zo/ X-Received: by 2002:a05:6a21:3390:b0:16b:abad:87c5 with SMTP id yy16-20020a056a21339000b0016babad87c5mr25271883pzb.10.1697417122962; Sun, 15 Oct 2023 17:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697417122; cv=none; d=google.com; s=arc-20160816; b=XHKACSC6TqGTyNdlLO5u9zBTEnckkJMsIJMZt/89IeLMz4gzkHVAkPGR4p3fhTlRtE +NZPWRH1MiDt3VxGdZmEOD09AVzivlFG/+2gZ88PjdFJV0nXybmTJyTZWXdgYFcXqu1L aFzzXxJBZFcDtHKm3sAPmPcShpfg7LO0SY0SZ22jgZWOlSlOrP2ehrIc6NH/7IyQYjEK YerhKyKECE9di3sEtIuiqQ5TOgd7s3RdEn9RofOgZxGFLN0x+2BPhUxx0v8uK2S60hyL VjerewhArC0n2pS/QY4gFzEJkBTlb9kXYdnOJI6S5tSvz3jr9lPNSWKHX0T68wtXLSyF UdSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:in-reply-to :mime-version:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=4thdf5vOiLjNrlhR2orFClc4haODcBFO8AN2JFM2cnA=; fh=PYo+Jlw0S5LuhXNSBzIremyu3Rx2j/6xwJKLijfS5GY=; b=GddcXOsOikPLxt4R4e8HLxJZeoiOgPAal4M1CGBPileOb5/nlp+/b11cYXbGQaG5J6 iBGWjdaGC95lSbGhH870k4tGR6AFoMIBrXp+rC4r//QQt/5g0lQSd08W12SQoE+2D6Vb z7/yMxs6vJLemg8UzXtzs9o2lMwz38aiH2/w3agcppQ3CTGMhNSU3FjOPMhJUp+oWu1L goKbvJz38S8+boKLfEbOwiID4531pFzcvsafxKEAq/T9w0whpV3ZfBcY29W420se2BiT MVTGN09/zeILZhlSje/pWysgRVXdN3r12/WyAvj21zZKVBhJeVBMtLC7D9+q8OJRRyPW MEgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PeDRdZNL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ft16-20020a17090b0f9000b00274985b2fcdsi5060221pjb.138.2023.10.15.17.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 17:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PeDRdZNL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 01EFF8077A70; Sun, 15 Oct 2023 17:45:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230478AbjJPAm1 (ORCPT + 99 others); Sun, 15 Oct 2023 20:42:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230490AbjJPAm0 (ORCPT ); Sun, 15 Oct 2023 20:42:26 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34434A3 for ; Sun, 15 Oct 2023 17:42:23 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20231016004219epoutp01c4ed45c5d52744660d31fbe97830d50c~Ob7amRv8r0099800998epoutp01e for ; Mon, 16 Oct 2023 00:42:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20231016004219epoutp01c4ed45c5d52744660d31fbe97830d50c~Ob7amRv8r0099800998epoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1697416939; bh=4thdf5vOiLjNrlhR2orFClc4haODcBFO8AN2JFM2cnA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PeDRdZNLcuLh7z5g9kFSW/wk51LkiJZyDZQ+6SUroc/HLojJ4caiDrbV3i3TaArFt fy/JhrNOF5Q2QF/oRySNRxBPYUGH+ZRy7xf/pzmENqE2ftxHgIhxN3gOp6kcgpoUWN xG0VMBYgrbNRAKo5KkZ6OBPDb5lgci4Tr9fM/z0w= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20231016004219epcas2p4cf1710a7794b601974475673c85d50e4~Ob7aTVSqS2621026210epcas2p4K; Mon, 16 Oct 2023 00:42:19 +0000 (GMT) Received: from epsmgec2p1-new.samsung.com (unknown [182.195.36.70]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4S7yxQ6vHCz4x9QC; Mon, 16 Oct 2023 00:42:18 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmgec2p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id B6.1D.18994.AE68C256; Mon, 16 Oct 2023 09:42:18 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20231016004218epcas2p19472bf83c7e69f73326a07141a021d98~Ob7ZZXoos1597115971epcas2p1-; Mon, 16 Oct 2023 00:42:18 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231016004218epsmtrp2b0992bb1f664dfed8e0b16647463804c~Ob7ZYyDpF1181411814epsmtrp2n; Mon, 16 Oct 2023 00:42:18 +0000 (GMT) X-AuditID: b6c32a4d-9f7ff70000004a32-e2-652c86ea40fc Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 19.57.08755.AE68C256; Mon, 16 Oct 2023 09:42:18 +0900 (KST) Received: from tiffany (unknown [10.229.95.142]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231016004218epsmtip2ce75f3cb6e92d4aa50e617a76f01c8aa~Ob7ZPUyhD2150521505epsmtip2z; Mon, 16 Oct 2023 00:42:18 +0000 (GMT) Date: Mon, 16 Oct 2023 09:32:00 +0900 From: Hyesoo Yu To: Vishal Moola Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: page_alloc: check the order of compound page event when the order is 0 Message-ID: <20231016003200.GA445850@tiffany> MIME-Version: 1.0 In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBKsWRmVeSWpSXmKPExsWy7bCmhe6rNp1Ug952C4s569ewWVzeNYfN 4t6a/6wW6/fdYHVg8dg56y67x6ZPk9g9Tsz4zeLxeZNcAEtUtk1GamJKapFCal5yfkpmXrqt kndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO0EolhbLEnFKgUEBicbGSvp1NUX5pSapC Rn5xia1SakFKToF5gV5xYm5xaV66Xl5qiZW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tr/rNarN93g9WBxWPnrLvsHps+TWL3ODHjN4vH501yASxRXDYpqTmZZalF+nYJXBnPvhoU tPJVHH7Yw9TAOJW7i5GTQ0LARKJp/xbmLkYuDiGB3YwSC26fY4FISErM+nySCcIWlrjfcoQV ougxo8SOYxvZuhg5OFgEVCWu/nABqWETUJc4sWUZI0hYREBTYuXfJJAws0CixN+p69lBbGEg e2fzBjYQm1dAV2LFm5MsECNPMEr8+7aLGSIhKHFy5hMWiGYtiRv/XjKBzGQWkJZY/o8DJMwp 4CRxbNFnpgmMArOQdMxC0jELoWMBI/MqRsnUguLc9NxiwwLDvNRyveLE3OLSvHS95PzcTYzg 8NXS3MG4fdUHvUOMTByMhxglOJiVRHjTg3VShXhTEiurUovy44tKc1KLDzFKc7AoifOKv+hN ERJITyxJzU5NLUgtgskycXBKNTAll12TPOjc+nXa28MnyhI5tjzbbn187mS/oOZv17nuWnNt +KHEYqR5+aOdidwK0z1Sh9+zR3083NB9XuWLknKfYJG02SPDbfcuNnlU3LfYdtRwes7tjV+L vk3L4Pq14mSr6i9uNTbJBr0Lm4r4ruYZJV9ds/b15z1PD99Jl5BIE3ExPnHtsLVDgp73hd2X C8Qf7vztwaZbcH3NehOzkEqj+X6xuqqhMX6V/7JmOdq+lHFynvJbrcHypPlptu3RJt90FLP8 7q2emHx2/eSjCk5T42MaWeweLPmUfGD/ISEuh1kpm5wbr05l2v268fuFyn+RH9n4BKS9ZBbK Rdwt+GzSkO0k+6risOfU8oNXFU8osRRnJBpqMRcVJwIA4uZzW84CAAA= X-CMS-MailID: 20231016004218epcas2p19472bf83c7e69f73326a07141a021d98 X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----.DGRwfvtDKQaTon4q7jBZTz_rY-uYfv-SaOoriR32EfX1D_r=_7c95_" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231012012153epcas2p34b8e9e8a898ace8d50411cadf937ef5d References: <20231012011106.2425309-1-hyesoo.yu@samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 15 Oct 2023 17:45:11 -0700 (PDT) ------.DGRwfvtDKQaTon4q7jBZTz_rY-uYfv-SaOoriR32EfX1D_r=_7c95_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On Fri, Oct 13, 2023 at 01:54:08PM -0700, Vishal Moola wrote: > On Thu, Oct 12, 2023 at 10:11:06AM +0900, Hyesoo Yu wrote: > > For compound pages, the head sets the PG_head flag and > > the tail sets the compound_head to indicate the head page. > > If a user allocates a compound page and frees it with a different > > order, the compound page information will not be properly > > initialized. To detect this problem, compound_page(page) and > > the order are compared, but it is not checked when the order is 0. > > That error should be checked regardless of the order. > > I believe all compound pages are order >= 1, so this error can't occur > when the order is 0. > Yes. All compound pages are order >= 1. However if the user uses the API incorrectly, the order value could be zero. For example, addr = alloc_pages(GFP_COMP, 2); free_pages(addr, 0); (struct page[16])0xFFFFFFFE21715100 = ( (flags = 0x4000000000000200, lru = (next = 0x0, prev = 0xDEAD000000000122),// Clear PG_head (flags = 0x4000000000000000, lru = (next = 0xFFFFFFFE21715101, prev = 0xFFFFFFFF00000201), // Remain compound head It is memory leak, and it also makes system stability problem. on isolation_single_pageblock, That case makes infinite loops. for (pfn = start_pfn; pfn < boundary_pfn; ) { if (PageCompound(page)) { // page[1] is compound page struct page *head = compound_head(page); // page[0] unsigned long head_pfn = page_to_pfn(head); unsigned long nr_pages = compound_nr(head); // nr_pages is 1 since page[0] is not compound page. if (head_pfn + nr_pages <= boundary_pfn) { pfn = head_pfn + nr_pages; // pfn is set as page[1]. continue; } } So, I guess, we have to check the incorrect use in free_pages_prepare. Thanks, Hyesoo Yu. ------.DGRwfvtDKQaTon4q7jBZTz_rY-uYfv-SaOoriR32EfX1D_r=_7c95_ Content-Type: text/plain; charset="utf-8" ------.DGRwfvtDKQaTon4q7jBZTz_rY-uYfv-SaOoriR32EfX1D_r=_7c95_--