From patchwork Tue Mar 7 05:20:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Stevens X-Patchwork-Id: 13162794 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 9DA07C678DB for ; Tue, 7 Mar 2023 05:20:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF0476B0071; Tue, 7 Mar 2023 00:20:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C9D856B0072; Tue, 7 Mar 2023 00:20:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B65526B0073; Tue, 7 Mar 2023 00:20:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A74A16B0071 for ; Tue, 7 Mar 2023 00:20:47 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 64458409B3 for ; Tue, 7 Mar 2023 05:20:47 +0000 (UTC) X-FDA: 80540952534.11.C3FB7E9 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf16.hostedemail.com (Postfix) with ESMTP id 9711818000A for ; Tue, 7 Mar 2023 05:20:45 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=LrljpWa6; spf=pass (imf16.hostedemail.com: domain of stevensd@chromium.org designates 209.85.215.173 as permitted sender) smtp.mailfrom=stevensd@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678166445; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=20CEHgBZB/knq/v8u1dqent5tn2IhUU6G+2xPJmjJ6k=; b=JFoiDwf46/4STjL0gZWiCh4gLJ4apLwxtf1st1qkZ4meIjnPXgaqJTtRYJIscjZ/2Th6qd uwF79u6z5ZiMCbWuhBHt563OmYXafHbOgE5UpU/gCyfcNcEBD6SHrIGE20UjNE+PfRwZDg IB2mzC1VR8lqtWHXbnBTFA6K0dsO4nQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=LrljpWa6; spf=pass (imf16.hostedemail.com: domain of stevensd@chromium.org designates 209.85.215.173 as permitted sender) smtp.mailfrom=stevensd@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678166445; a=rsa-sha256; cv=none; b=DwBT7OMutwgAkwn7Ycvp0HrbF1dOa16PubOKGq7bU3s4kgmDR47uB+NELgrzZrkZ/9qsTG Tdu8hOfr+VzM/1MuhQeUM2MKNdWRTts59CrZo5dakobNoRsziz412vrCU6r8GSOi4PHe7f 35Go/nQ6FlMQVYC6evvb8be4T+Z/EuE= Received: by mail-pg1-f173.google.com with SMTP id s18so6948655pgq.1 for ; Mon, 06 Mar 2023 21:20:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678166444; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=20CEHgBZB/knq/v8u1dqent5tn2IhUU6G+2xPJmjJ6k=; b=LrljpWa64w/OvxKgj7tq2aRMAPKskK+arq0+8oZuMtFp6/+4iMBYkokTvHm5bASffo BUNfBUPE0w+bDoaIk6EfXbE1vXE0u/VM9TMfzgcGXuP36HYKNHZkXLljqwkkUlNbybYw qnPLqtY8IzMsTjn+UG1nrFrPgx7yUaKBAI3Ac= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678166444; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=20CEHgBZB/knq/v8u1dqent5tn2IhUU6G+2xPJmjJ6k=; b=KiCBjBD2JRUkj3VyJkoPHem5jQaog0ldPuYkerqLAfQQtUBVhcBTMBiMlyLou3LAt4 J7qLd9ieiuE5febVoRfDWJsJ2vny0ztDB428ufjTqGFXwvr0hSudqhsifNWGc72vZcX1 D0ZkOvVmhsrFH1bIwby42G6zLDf3hErx5tZYv6mAyRYZCoCz5nW7D50SB32wVttHhXZl ZdMf8ZoAp0NfDWLNHWepXZJ4KpUEapTUsZDgdyyuolu2bnWFmVwIoFuQ8Fq0IvzJ60kl ED3K9aZO0ux9FVX2xuZWfaVvENEqR/7JWU6P5pBSnpcaLwFnv91GhI7qvd6QB7O5XSPb STXA== X-Gm-Message-State: AO0yUKUsdQAzRiNqw7de0L6M4DqCQ2kyP1+1RY83YDjsEyagJxLpYOsF PVZb7XnUfKVRKOjACI8d8LgFAHXax+8rhdRUr+A= X-Google-Smtp-Source: AK7set+QPVgc7195ffL/2bqmra2B4t+KPYNOjqUJ+WyPG0pIrD5U2xmSZpX7ihZmyKeQ8jBDSXcJLQ== X-Received: by 2002:aa7:956b:0:b0:619:d5c2:e97 with SMTP id x11-20020aa7956b000000b00619d5c20e97mr8067843pfq.2.1678166443789; Mon, 06 Mar 2023 21:20:43 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:1f73:9034:ce28:4421]) by smtp.gmail.com with UTF8SMTPSA id 1-20020aa79241000000b005a7ae8b3a09sm7146849pfp.32.2023.03.06.21.20.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Mar 2023 21:20:43 -0800 (PST) From: David Stevens X-Google-Original-From: David Stevens To: linux-mm@kvack.org, Andrew Morton Cc: Peter Xu , Matthew Wilcox , "Kirill A . Shutemov" , Yang Shi , David Hildenbrand , Hugh Dickins , Jiaqi Yan , linux-kernel@vger.kernel.org, David Stevens Subject: [PATCH v5 0/3] mm/khugepaged: fix khugepaged+shmem races Date: Tue, 7 Mar 2023 14:20:33 +0900 Message-Id: <20230307052036.1520708-1-stevensd@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: hswrqw8bhj7811mjefot3oi86mgeepob X-Rspamd-Queue-Id: 9711818000A X-HE-Tag: 1678166445-516549 X-HE-Meta: U2FsdGVkX18iviy9TBpylzwhsHJKRfznfZGsQzdHfavqaZQHwlfj2Pw+ilvNmxTJtimYaEcDetq8m0KZGCd7xKF6dC7/7vOE1qRxQDirf8G96+jruvmnjl8MA+qcMiPL/zlTUd4Aa5+YB8DX8kKcINLHVIs0He9DBE+F8AtvFD+lZrQoO92yV4ppwnsPq/BX2K/whEPBXpS3L+0YyW+1oIcIoBXkcFipMW+wCJwiWQGzKU3l53OMxCldLrv/+/1MDxVVD6JF2G5iMtk5WNWqd5fW46eZePue0zlEdC7gTQUVkcKDMEZE4RXW4zBxNo7NgLaW68qg8Xg5oVZPBb5rVk3csFPP/MSOIlBNXbImmgFIAm42wtSfazZgBE4yJldRCVtzxJBxeIT8zdVXobQh1VFU1v8my8v1abHSUAhj7wwx77lYfdDLyqxB0EF+SharHoQQdsQB0lmVNW4Lz9/H7qqg/8hV8ZqzXP1I4scDmGc5pmUcbqy7SP9yPTEN44b3S+nfPBoqNDtqjJ24dEpKzzQMH4SjAmGoZrenzQLouTuduk1rDbU/AB7wjXSKotFTiny7VLffkOdpSRMdRIK6NDHTLymVPbfq8boCoW407ShwlOYAy0vWPujb44QZIiMZ0RWUxluNvSBalZIlKykwuBb78C6v5n+qMIA2bHsAQafuQLN7Lol+3a0E87YXtsQSdrmT512aTKGRLpmxB8KXdco5FfRTnODLJRllcWWxsYO8Z0LLnq3ijzr/q/e2l0uMkdYzeLClkJOea7dfr1LFed/9LNjaBZBav9E7XhmkQV53+wJWF3UqoV57NggVUn3dYCSMRwzQ4iB+GrsCpjPBPnVqVCUTnMiNh/PhZhg1YbascMU5E/7oGZOscftuSPn4OS+OWIzm/VP4NzM9opu8+/i452EoDKH2BMaLS6AHYskJCwhQRVviFjw72hlCeGn5et2YgfSYIsLGytieUZU 4DDoxdTg wxwqkTeq4T6GZ3quSYayy2P51NF6wy48c8MSll1+an39qEH8TkSI4wQqrUsAFhqArpBbNMf4aXo0M+dgCnKRSSL+ZtSwdVsDMXbDVgZXuLRZrfBEcli/nsSb768n+7U7azpYNScPKpsSTpiJRq21lip61jwFwHWFU1z1fIXTBQItUbrY52hXnJeA22U8OpuQaJ0L5dr7Y5GhhOMD0D+GFcZbzgH2uZT6PYoaqs/x4hFqiIKu07Zh5oRhLZkToRK4gAcgM+vRrGLpTwxQS7UyotmiCN2/H9vMJ8/4Hi/xvRn2IvLo3Gp7zuZmbyd629wF4PLqh5hYPcoZh2xNSEoLn+faLQvltF36GtnDk 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: From: David Stevens Fix two races in khugepaged+shmem that cause issues with userfaultfd and lseek, respectively. v4 -> v5: - Rebase on mm-unstable (9caa15b8a499) - Gather acks v3 -> v4: - Base changes on mm-everything (fba720cb4dc0) - Add patch to refactor error handling control flow in collapse_file - Rebase userfaultfd patch with no significant logic changes - Different approach for fixing lseek race v2 -> v3: - Use XA_RETRY_ENTRY to synchronize with reads from the page cache under the RCU read lock in userfaultfd fix - Add patch to fix lseek race v1 -> v2: - Different approach for userfaultfd fix David Stevens (3): mm/khugepaged: refactor collapse_file control flow mm/khugepaged: skip shmem with userfaultfd mm/khugepaged: maintain page cache uptodate flag include/trace/events/huge_memory.h | 3 +- mm/khugepaged.c | 259 ++++++++++++++++------------- 2 files changed, 142 insertions(+), 120 deletions(-)