From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36516C3F2D2 for ; Fri, 28 Feb 2020 13:47:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA67624699 for ; Fri, 28 Feb 2020 13:47:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA67624699 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6D1E46B0007; Fri, 28 Feb 2020 08:47:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 682C16B0008; Fri, 28 Feb 2020 08:47:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 570F56B000A; Fri, 28 Feb 2020 08:47:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 3CDC36B0007 for ; Fri, 28 Feb 2020 08:47:30 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D7BC73D12 for ; Fri, 28 Feb 2020 13:47:29 +0000 (UTC) X-FDA: 76539663018.03.rose29_5e6e791aae139 X-HE-Tag: rose29_5e6e791aae139 X-Filterd-Recvd-Size: 3677 Received: from outbound-smtp07.blacknight.com (outbound-smtp07.blacknight.com [46.22.139.12]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Fri, 28 Feb 2020 13:47:28 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp07.blacknight.com (Postfix) with ESMTPS id 729641C3B1A for ; Fri, 28 Feb 2020 13:47:27 +0000 (GMT) Received: (qmail 11603 invoked from network); 28 Feb 2020 13:47:27 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.18.57]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 28 Feb 2020 13:47:27 -0000 Date: Fri, 28 Feb 2020 13:47:25 +0000 From: Mel Gorman To: Vlastimil Babka Cc: Andrew Morton , Dan Carpenter , linux-mm@kvack.org Subject: Re: [bug report] mm, compaction: capture a page under direct compaction Message-ID: <20200228134725.GK3818@techsingularity.net> References: <20200224062949.mhyi2ntdiq4vbptm@kili.mountain> <82147552-be4c-84cc-53d8-f00711859427@suse.cz> <20200226175614.5dfe21b53cad9f8bca084a2b@linux-foundation.org> <18b0df3c-0589-d96c-23fa-040798fee187@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <18b0df3c-0589-d96c-23fa-040798fee187@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Thu, Feb 27, 2020 at 08:45:46AM +0100, Vlastimil Babka wrote: Bit late to the game but; > ----8<---- > From 3118d9bea8a0fcef294915220f824674fb039ec3 Mon Sep 17 00:00:00 2001 > From: Vlastimil Babka > Date: Wed, 26 Feb 2020 17:53:54 +0100 > Subject: [PATCH] mm, compaction: fully assume capture is not NULL in > compact_zone_order() > > Dan reports: > > The patch 5e1f0f098b46: "mm, compaction: capture a page under direct > compaction" from Mar 5, 2019, leads to the following Smatch complaint: > > mm/compaction.c:2321 compact_zone_order() > error: we previously assumed 'capture' could be null (see line 2313) > > mm/compaction.c > 2288 static enum compact_result compact_zone_order(struct zone *zone, int order, > 2289 gfp_t gfp_mask, enum compact_priority prio, > 2290 unsigned int alloc_flags, int classzone_idx, > 2291 struct page **capture) > ^^^^^^^ > > 2313 if (capture) > ^^^^^^^ > Check for NULL > > 2314 current->capture_control = &capc; > 2315 > 2316 ret = compact_zone(&cc, &capc); > 2317 > 2318 VM_BUG_ON(!list_empty(&cc.freepages)); > 2319 VM_BUG_ON(!list_empty(&cc.migratepages)); > 2320 > 2321 *capture = capc.page; > ^^^^^^^^ > Unchecked dereference. > > 2322 current->capture_control = NULL; > 2323 > > In practice this is not an issue, as the only caller path passes non-NULL > capture: > > __alloc_pages_direct_compact() > struct page *page = NULL; > try_to_compact_pages(capture = &page); > compact_zone_order(capture = capture); > > So let's remove the unnecessary check, which should also make Smatch happy. > > Fixes: 5e1f0f098b46 ("mm, compaction: capture a page under direct compaction") > Reported-by: Dan Carpenter > Suggested-by: Andrew Morton > Signed-off-by: Vlastimil Babka > Cc: Mel Gorman Acked-by: Mel Gorman -- Mel Gorman SUSE Labs