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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3D0FC7EE2D for ; Fri, 24 Feb 2023 17:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbjBXRhr (ORCPT ); Fri, 24 Feb 2023 12:37:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjBXRhq (ORCPT ); Fri, 24 Feb 2023 12:37:46 -0500 Received: from mail-vs1-xe2e.google.com (mail-vs1-xe2e.google.com [IPv6:2607:f8b0:4864:20::e2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 284EB6A78A for ; Fri, 24 Feb 2023 09:37:45 -0800 (PST) Received: by mail-vs1-xe2e.google.com with SMTP id v27so413810vsa.7 for ; Fri, 24 Feb 2023 09:37:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EWzoZiGGKJU76InhrcpfnYDyqrXlTAbTxm3TVdiVpGQ=; b=rdlXLkxEkG9cQGBs2asmja/R6u0fRQWO7Lr54YW0AujGE+cnUoZ9o/o73COB3fUhHn Y/duNkM3PlYevse6re7o2nFCYYW3PxT23MLPbgvnnggud59/p+ygCbTBrBYFoLwG6DNA Hwpmr1HPSsXmIL80Zy0fVi7wfJ6GKqsM1QVfve8jYi0+glaEScOrdCpBe//CXNkOU5Nn M0nPUqQTG0S7WR8STO/pkFHcnXKXdfMKSncWQghRBcydDWxCwbsdATp+u3J37lgt2Cap 9l3VK95sek0xgJ4jOjQrRr/DyWqwoaEqXow7F0PBCEy4AsiONsesXUuYEkvNuxZwQPqv Lp7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EWzoZiGGKJU76InhrcpfnYDyqrXlTAbTxm3TVdiVpGQ=; b=WHcz3acy6bMwUjWg3d2FL5eJsYpCKMUEltrJ7qQOYEAnYYfLnSdXTxpdhpPS/9UKsO VBwrx0vpP+/F6TUJ+awPaJuRRco/cGPcJmUcA3KFU3fjMyEvatHpdOmKfBVqVNqGUSIz o63s+qWEf1j7gQXkPsor3oOj+/QV5O0euVFu6Ti6XFSPnX8sPl85FCbJrxsMya/CBet7 e7852fY9UCOxM0ue8TZoYM8hrAye8ySfK4vGU4xtRLn0AfezCDE9inV6y+zDRtjERNJj e9/IHDYG0MbE+paH99uEiBXzpOz+eh8FwxR9Df+aUOb9ZfWQOmS5lvEtzA194RGUibPW s8kA== X-Gm-Message-State: AO0yUKW/lRFyZ83XL2Pv6AXw/ukNsud3X4MEBCZzPtMFxaaGLQ7o/SKC psD5iEJYudSQzyJKwppkcI2z04xb7eiMVumgD9TApg== X-Google-Smtp-Source: AK7set+CQuj6d6BY8B+pqCObyMjUGt/K6CzwPWQvAyE66Bi1xIcAnW7ZLX/TDZpKnKjRmQLbxzmEq22JsZRrzyqK5Sk= X-Received: by 2002:ab0:38d3:0:b0:67a:2833:5ceb with SMTP id l19-20020ab038d3000000b0067a28335cebmr507770uaw.0.1677260264194; Fri, 24 Feb 2023 09:37:44 -0800 (PST) MIME-Version: 1.0 References: <20230218002819.1486479-1-jthoughton@google.com> <20230218002819.1486479-47-jthoughton@google.com> In-Reply-To: <20230218002819.1486479-47-jthoughton@google.com> From: James Houghton Date: Fri, 24 Feb 2023 09:37:08 -0800 Message-ID: Subject: Re: [PATCH v2 46/46] selftests/mm: add HGM UFFDIO_CONTINUE and hwpoison tests To: Mike Kravetz , Muchun Song , Peter Xu , Andrew Morton Cc: David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , "Zach O'Keefe" , Manish Mishra , Naoya Horiguchi , "Dr . David Alan Gilbert" , "Matthew Wilcox (Oracle)" , Vlastimil Babka , Baolin Wang , Miaohe Lin , Yang Shi , Frank van der Linden , Jiaqi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int test_fork(int uffd, char *primary_map, size_t len) > +{ > + int status; > + int ret = 0; > + pid_t pid; > + pthread_t uffd_thd; > + > + /* > + * UFFD_FEATURE_EVENT_FORK will put fork event on the userfaultfd, > + * which we must read, otherwise we block fork(). Setup a thread to > + * read that event now. > + * > + * Page fault events should result in a SIGBUS, so we expect only a > + * single event from the uffd (the fork event). > + */ > + if (read_event_from_uffd(&uffd, &uffd_thd)) > + return -1; > + > + pid = fork(); > + > + if (!pid) { > + /* > + * Because we have UFFDIO_REGISTER_MODE_WP and > + * UFFD_FEATURE_EVENT_FORK, the page tables should be copied > + * exactly. > + * > + * Check that everything except that last 4K has correct > + * contents, and then check that the last 4K gets a SIGBUS. > + */ > + printf(PREFIX "child validating...\n"); > + ret = verify_contents(primary_map, len, false) || > + test_sigbus(primary_map + len - 1, false); > + ret = 0; > + exit(ret ? 1 : 0); > + } else { > + /* wait for the child to finish. */ > + waitpid(pid, &status, 0); > + ret = WEXITSTATUS(status); > + if (!ret) { > + printf(PREFIX "parent validating...\n"); > + /* Same check as the child. */ > + ret = verify_contents(primary_map, len, false) || > + test_sigbus(primary_map + len - 1, false); > + ret = 0; I'm not sure how these 'ret = 0's got here -- they will be removed. > + } > + } This else block also runs when fork() fails; we need to fail the test instead. > + > + pthread_join(uffd_thd, NULL); > + return ret; > + > +}