From patchwork Thu Mar 2 01:26:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13156625 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 E03DBC678D4 for ; Thu, 2 Mar 2023 01:26:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EB536B0071; Wed, 1 Mar 2023 20:26:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59B386B0073; Wed, 1 Mar 2023 20:26:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 463756B0074; Wed, 1 Mar 2023 20:26:35 -0500 (EST) 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 3976D6B0071 for ; Wed, 1 Mar 2023 20:26:35 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1ADEA1C604F for ; Thu, 2 Mar 2023 01:26:35 +0000 (UTC) X-FDA: 80522218350.29.4873E28 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf19.hostedemail.com (Postfix) with ESMTP id 52EAC1A0006 for ; Thu, 2 Mar 2023 01:26:29 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=T0RU8ZVD; spf=temperror (imf19.hostedemail.com: error in processing during lookup of ying.huang@intel.com: DNS error) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677720393; 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: references:dkim-signature; bh=FSEH5LnspoqTh9QYbWEsPw3XEsL2ITEOQARpSYMOJPE=; b=VVnWe1x79N++1V9PgTV7HcbJ4C6m64yM8Fgb/lF6SBG6QmLLcuVIM06wgcKxFbW+a0h16f /CXfAGZTdeXRYD3o53UKmf8PI2J+WGoQh7eZ+CWxLTATjtqpX5g2sr/tvZQbkp0xRuokO8 OemELeQM+xx23olWTRLM+omNt1yg3q4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=T0RU8ZVD; spf=temperror (imf19.hostedemail.com: error in processing during lookup of ying.huang@intel.com: DNS error) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677720393; a=rsa-sha256; cv=none; b=YQcuf8Bl7M+eX7b5QBJ/utW/r8f4gV0/QdJXbCcu+LZBMBKLXxZKf9TT3iDk6B1xGyQLYX S1z0lnCFCoM3BFkRe4zmkZ4i6KRWZkLKtsmt2DzeFDNYV3AFLiljNpHQhmCRVzNiu60xDn yaedNavakkNd4dEtq5zpap03nupjbIg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677720390; x=1709256390; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=pGmuTevQ07eJFP0ypp19WPyXeC9s3DN8CSY+tvCbLVs=; b=T0RU8ZVD7R7vJoGtjz9+n7SLV175J3AKFN+WFaRVIsrDT5sqdx9ATi1h Zsgm4DDFyZdH6QtQpJZDMg+vehRSGbWe/CvABpqmuieE4xJnQt/HeGvhf x3B2N4HRDPEf9R5mw4txKFgaMv0jJgFBQha+Zyuox8vtm/trg8SnDv0gF jZa/yOT9SO25rLxIDDkPtD85J5xuU7LmSg206BfeErAUWyyOxBmzM3G3J iVZ1Z1MTWBDJlHNBpw0q/r8NsvC1L1OuvxBXnjeKG6qbeQ7R4vzJV2jDe 8hsxw2hTn4glCLtP0qcSD+YmcRzSm08da77pk6/TBHwGQ5buwU7Hdalqn A==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="315002944" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="315002944" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 17:26:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="652226939" X-IronPort-AV: E=Sophos;i="5.98,226,1673942400"; d="scan'208";a="652226939" Received: from yhuang6-mobl2.sh.intel.com ([10.238.7.50]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 17:26:23 -0800 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Linus Torvalds , Baolin Wang , Xin Hao , Zi Yan , Yang Shi , Oscar Salvador , Matthew Wilcox , Bharata B Rao , Alistair Popple Subject: [PATCH] migrate_pages: silence gcc notes for mis-casting Date: Thu, 2 Mar 2023 09:26:10 +0800 Message-Id: <20230302012610.17055-1-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 52EAC1A0006 X-Stat-Signature: qp8d77xjarnkizk4tqk6n3r37s3hn4qw X-HE-Tag: 1677720389-914855 X-HE-Meta: U2FsdGVkX19fLHmWy7+Rm+JpEJhKrCOu24+8oyiuOeOxIBV7SP64ILu/BJNCkiDVBHMKmQxAI3HYAD+PuodR14SRj0ds+HfNAaE9piQ/cp2tMDQY7InvkF9HOmFdKIu0mZTs2h1Q980Qe5Pa2/i4oS4lGwwO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TIcgWZtQHANN7IpELXkqLRyQAHZoB/uZnQRXQehvdODIQH/BzMoUuodgHAUuk9g1qiwSbYefggaAngqkcRqUHJNyWjQmxBJOcaRXOQmU+1UEreqLJmX66/6zjQWcqAEnx6PqK2OrqGpk0obasRrf9yrhN0tbj7iO0Wn06rFFwr4/yk1wFWpGMDYIbQ1NSHmqXOHG0UE= 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: The following GCC notes was reported for commit 64c8902ed441 ("migrate_pages: split unmap_and_move() to _unmap() and _move()"). mm/migrate.c: In function ‘__migrate_folio_extract’: mm/migrate.c:1050:20: note: randstruct: casting between randomized structure pointer types (ssa): ‘struct anon_vma’ and ‘struct address_space’ 1050 | *anon_vmap = (void *)dst->mapping; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ The casting itself is safe. Because we only use dst->mapping to store the pointer itself temporarily and dst is a newly allocated folio and not used by anyone else during that. But the notes should be silenced and some comments are deserved. So, we do that in this patch. Fixes: 64c8902ed441 ("migrate_pages: split unmap_and_move() to _unmap() and _move()") Signed-off-by: "Huang, Ying" Cc: Linus Torvalds Cc: Baolin Wang Cc: Xin Hao Cc: Zi Yan Cc: Yang Shi Cc: Oscar Salvador Cc: Matthew Wilcox Cc: Bharata B Rao Cc: Alistair Popple --- mm/migrate.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index c17ce5ee8d92..53fcc23025c7 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1047,7 +1047,16 @@ static void __migrate_folio_extract(struct folio *dst, int *page_was_mappedp, struct anon_vma **anon_vmap) { - *anon_vmap = (void *)dst->mapping; + struct anon_vma *anon_vma; + + /* + * 2 steps assignment to silence gcc notes for mis-casting. The + * casting is safe. Because we only use dst->mapping to store + * the pointer itself temporarily and dst is a newly allocated + * folio and not used by anyone else during that. + */ + anon_vma = (void *)dst->mapping; + *anon_vmap = anon_vma; *page_was_mappedp = (unsigned long)dst->private; dst->mapping = NULL; dst->private = NULL;