From patchwork Thu Aug 23 20:59:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 10574573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCAFA139B for ; Thu, 23 Aug 2018 20:59:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5F672C7A0 for ; Thu, 23 Aug 2018 20:59:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99A092C7A5; Thu, 23 Aug 2018 20:59:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AC532C7A0 for ; Thu, 23 Aug 2018 20:59:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 394E96B2C08; Thu, 23 Aug 2018 16:59:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 31E006B2C09; Thu, 23 Aug 2018 16:59:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1971F6B2C0A; Thu, 23 Aug 2018 16:59:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-vk0-f69.google.com (mail-vk0-f69.google.com [209.85.213.69]) by kanga.kvack.org (Postfix) with ESMTP id E591B6B2C08 for ; Thu, 23 Aug 2018 16:59:31 -0400 (EDT) Received: by mail-vk0-f69.google.com with SMTP id 11-v6so2656285vko.21 for ; Thu, 23 Aug 2018 13:59:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=WScNzPijogN31b3MQE7ypuetUbwMbjDinmHl8orDy+k=; b=XzJX7Yy3fjcenrtiLkm3zo2bZEBwN1AZvt7+scXnYjZuUTUAtIQU1n1HsyZC6StAZK BIJxUFL8i9kqz66z3OpZUc8hDW5MJO0yG6pftikFIdLU319Rt1O+a745y7ExaQE2UOQ9 53ELyB419GrCZ1tBFNMwZFE6P8JF4gCj0/gn7EK3gwLgB3FcWw+K4tl79uWrip7zQ/za JlVnlMnQJ+7E+FJ8kLa6xDlF4TTCMWrIEkyJpx98Amobwir+SWzqs/LMQabDz/LokGiX 8qYpCKftw3OPGuucsH8dvBfQRxX6aNUJ4ISmOL4TnnUlaNKaTHev5o0FWmM9gslC+7aL sFFQ== X-Gm-Message-State: AOUpUlFkg0BcMMYUwahEdPdJ3XtQvh1bSM3R9CU6gBgx1kqg/ctDU2fK pZ/lX6nhkCy2EszFD2WJ4iQhvNhcgPfAAEHNnMnRybZ6o5no3wjKjzL/vbdVtDyRJDmxNFsZUYa Asl4rLkI9E6NpKgCGAxIP7R7vuSd7uHAGhdW2EsAb0wYvGWRDPyyrC8ahJ/zUfsywUw== X-Received: by 2002:a1f:5641:: with SMTP id k62-v6mr41158459vkb.12.1535057971620; Thu, 23 Aug 2018 13:59:31 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxp0km5B2waxUktuXm5YYK/cdDYRsD08yatX09Dw21mam1mOFhpW8YqH+NBky3TUWCEWoJT X-Received: by 2002:a1f:5641:: with SMTP id k62-v6mr41158435vkb.12.1535057970954; Thu, 23 Aug 2018 13:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535057970; cv=none; d=google.com; s=arc-20160816; b=JHjomAEam9SR6GjupFPDl1ArmOkR/tBWAUrFDrP+2lIBmgneqwOGIhvuXJl7z5yfdl XeKtGPeSJwjVOw7jb+RaCXY3bN6IQHWYYARtokgb09wC9KXKznfgXT7WpCapiBQU/f6z iy7Hj4hJXx9zQogdFBsu5tXEfozRsg8pHigB8+/7cTHSl6GnqghuYv2L9k1y88D0nHm5 22XnWfXYcIT9fJIb/bzg+Ko3DNLkizII+/1wbWdWk5IqYdQR5tHiCHQn6dv6fG3xjK5K OuAboxHEEU3UxECYZ1F4cGzE8q8eHiu3TGg+N7corr1uOEgmmJXaHeElIWm6dWtiMwL/ yxgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=WScNzPijogN31b3MQE7ypuetUbwMbjDinmHl8orDy+k=; b=tuz5VwCuPU6xI5Qf7iml2YR28XvOGTAZdfoYYJgCFT1SyekiXofRQt5qP5vpuPZaTg fMpBaeKRckuZtyPJ1gr369x0Q2HIGN1vDLO4yAfKh3QJrTn4sJj09nwSekgqSm6nId3Z sJepUfjYJ/KTtoJ6I4SlOiIIM/AeKFrwnHrcipnHzvQF0YN5fLuuTSGCa7u2UMuRPFVI mA2ANq3kRUUIzRmDv4Hc3vzDp6CGQMNTG0gqCjzvNa+GpwnIBwqBwjoJfr9Pvl79q/+b ahHo7CUVnNmUW3KeTbmcX2/tJdVcvwkyKZ03+gre46abi0lP1RZikokYtjLLvRoOTq0x 4jjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="hZ/tritc"; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id c48-v6si2305163uad.207.2018.08.23.13.59.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 13:59:30 -0700 (PDT) Received-SPF: pass (google.com: domain of mike.kravetz@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="hZ/tritc"; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7NKwWqO144639; Thu, 23 Aug 2018 20:59:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=WScNzPijogN31b3MQE7ypuetUbwMbjDinmHl8orDy+k=; b=hZ/tritcKljTWwRUeXZf6e7ET1BoqSwqECQ79xkfA2C22v1/LBf/qa81OjpKw0NLckaE ZLAMo9lC7adTa4s0fT//R80aVo7dPM5cl237mJlwmS28FeKYN84Mhf0nv8SDgcp0j25T 9bCNbh7G3J1xmG2Qwq8MVqI9elsjJUlj1LjvlAiY5RBf1LUny8RPY5zGgHQOkzujoLT1 VWherYTRMTuBhwCnOZeRe0aAvuxS+2GwQH4sZsvP/720y+s3efnQSPm4ZQi6g8ARZttD dNNlZNDA/S8Wh3IFrQ+TmdMYI6wQus8By83cwyE1RWzEx4Gs0zELab5/uQPGW6iui4IX rA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2kxavu3t54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Aug 2018 20:59:25 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7NKxOCi022579 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Aug 2018 20:59:24 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7NKxNRn015248; Thu, 23 Aug 2018 20:59:23 GMT Received: from monkey.oracle.com (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Aug 2018 13:59:22 -0700 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Kirill A . Shutemov" , =?utf-8?b?SsOp?= =?utf-8?b?csO0bWUgR2xpc3Nl?= , Vlastimil Babka , Naoya Horiguchi , Davidlohr Bueso , Michal Hocko , Andrew Morton , Mike Kravetz Subject: [PATCH v6 0/2] huge_pmd_unshare migration and flushing Date: Thu, 23 Aug 2018 13:59:15 -0700 Message-Id: <20180823205917.16297-1-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8994 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=656 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808230215 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: X-Virus-Scanned: ClamAV using ClamSMTP Correct a data corruption issue caused by improper handling of shared huge PMDs during page migration. This issue was observed in a customer environment and can be recreated fairly easily with a test program. Patch 0001 addresses this issue only and is copied to stable with the intention that this will go to stable releases. It has existed since the addition of shared huge PMD support. While considering the issue above, Kirill Shutemov noticed that other callers of huge_pmd_unshare have potential issues with cache and TLB flushing. A separate patch (0002) takes advantage of the new routine adjust_range_if_pmd_sharing_possible() to adjust flushing ranges in the cases where huge PMD sharing is possible. There is no copy to stable for this patch as it has not been reported as an issue and discovered only via code inspection. v5-v6: Rename and update 'sharing possible' routine as suggested by Kirill. v3-v5: Address build errors if !CONFIG_HUGETLB_PAGE and !CONFIG_ARCH_WANT_HUGE_PMD_SHARE Mike Kravetz (2): mm: migration: fix migration of huge PMD shared pages hugetlb: take PMD sharing into account when flushing tlb/caches include/linux/hugetlb.h | 14 +++++++ mm/hugetlb.c | 93 ++++++++++++++++++++++++++++++++++++----- mm/rmap.c | 42 +++++++++++++++++-- 3 files changed, 135 insertions(+), 14 deletions(-) Acked-by: Kirill A. Shutemov