Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp932653iog; Mon, 13 Jun 2022 16:36:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u0J+BvOiwmsO9G8cSy++3ao3sJCxR69vK2x2319pWk44uny60qL7xcvsmxq8YFrFZJxnFZ X-Received: by 2002:a17:903:240e:b0:168:ea13:f9e0 with SMTP id e14-20020a170903240e00b00168ea13f9e0mr1546392plo.6.1655163414310; Mon, 13 Jun 2022 16:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655163414; cv=none; d=google.com; s=arc-20160816; b=Z738H9qrcxr8AyZAQqzte3px0sRgrSM2giNPnY9hkhlGiWA76xZ9BTX6m88U4MWtT5 adTNetwMlyLtYu16RXb8W/fnfU6WMZJLeqV1taitHi4El7F+ludmXiIPxrvnNc//Y0jX jfm2Rj7UZCYHtmcSMTzyqWITvnQVkApYv6jumHOVCGlfP5VB69mWJWYS0yKm0bG8gZ0k NTqYlg2YjMlOS1pJmFMNY2sjHzi/Q7/3/ci3m2HatSGQGXTqIIFXNdJjQKWgQhiCD/d+ /oILWuzJPicL7Tx/g9KNxzr/4LLPnIN9IV+SJe9sb6j+CF5JMb3ZKfK9X9Z1eMLF1oKt ciFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=Lpl6bFxJI4CHRgZzmX1LV+v0qDroFLN/nvNicZhBWbk=; b=ID5TsMtEwurJeDXyaO2+9cE+edU4HYgZvu9403IyAN9UMXBh4TL8RVHjT3w9Lu2/8T 97uP0qSVoIZzgepsscykk5nQVaTzA9aLHfu+ZvwrX+dpMQRLKD16QIls+REJEulDS3t7 IcAZmPjrvjSnbmDHJx2P04QgHwjBHn4jDTTPJnywRcHbsB1lV79soM6G2tzUmlRjXQcJ 5D90bhtAhkGy1xcUORlBdMc7vXgGf+cdvbWXQCdPSw14CylPCYVrVmnKa+mqpN7e9wKe R+lMpr/jFLZzr82kKwshdwy47Xqb8qGHJ9/VcyuEm//4wRLv0WtJThkXvaThE1fS47zj A/uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PBbqm2oE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a056a00084700b0050a6c1711d7si12279141pfk.336.2022.06.13.16.36.41; Mon, 13 Jun 2022 16:36:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PBbqm2oE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231401AbiFMXdz (ORCPT + 99 others); Mon, 13 Jun 2022 19:33:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbiFMXdu (ORCPT ); Mon, 13 Jun 2022 19:33:50 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 801E43055C for ; Mon, 13 Jun 2022 16:33:49 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id h190-20020a636cc7000000b003fd5d5452cfso4059613pgc.8 for ; Mon, 13 Jun 2022 16:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Lpl6bFxJI4CHRgZzmX1LV+v0qDroFLN/nvNicZhBWbk=; b=PBbqm2oEvfRdfqUL7Z30R+/pfa0TDaOZnOfFZ0FGkyyXTVfaeA859rqjWm5M1jgU4x x9JF9CHjapYA+Mh3kZOTZBfRwi95ukBYi4SdXiCXBziNv0P/HPw9E1dCWO6gbH+BcCKm tkhDkanIMftPysWbsqKlgR9QcfvPiyPBDZ/GSuklEWBnmW3oudZLo8ywT96P48LV6iA4 XmsVCsryoiDxhn+5j4mLRhSC2gJiFeyyEotYhoPswCKK6KwnReLTepOho7gwxE37W1Zi K/rIYy1sy8uQjBLmW9Eh+KI/HR8kZ34ztVrGSb3dFKCZ8WMgaXsxVEFfLfbbLSPqJGOj 6gTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Lpl6bFxJI4CHRgZzmX1LV+v0qDroFLN/nvNicZhBWbk=; b=bMvAOz+Tnp76BMeN0cUjPaIQ0zTGpC2Th7CsWzPMP2v8BvtjphUi/Sh8rOzQ8g6wsC FelDTmIgNVZzvCtS4qbcofr6Iq+AbqWQRUIqd7nLY3SGge49RYQda5xM7tuvLgTXHqe0 M4yH9wCtDygADYuUn5JhE24XY2L86bNi5B+8ie02OP15ylVQ2w6gQpNYU/Rt518caeRm jLGSrcd9lv+6UjnVbDSqPKYakUQLkU3tFLUJ1sXsPw/v7TphD0aAYcIbP4k0D/86EI0w 3PK9SXonnfmMO8zT7rOd4fpgWpA4CYujZnDxSSZ8OwD5tgxaD0ImKfbc8Zvgg8UkMIvz ZpTQ== X-Gm-Message-State: AJIora8w13Mq+BrKZD4a0i8527KhMIP59W1XBCBgkyULf5Cr4I+PRlol ME0ZNnTo0DjalrcAANlQTegFoqfBfIA= X-Received: from edliaw.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:4be]) (user=edliaw job=sendgmr) by 2002:a17:90a:e7c8:b0:1e6:92fe:84c2 with SMTP id kb8-20020a17090ae7c800b001e692fe84c2mr1259645pjb.194.1655163228891; Mon, 13 Jun 2022 16:33:48 -0700 (PDT) Date: Mon, 13 Jun 2022 23:33:21 +0000 Message-Id: <20220613233321.431282-1-edliaw@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH v1] userfaultfd: selftests: infinite loop in faulting_process From: Edward Liaw To: shuah@kernel.org Cc: axelrasmussen@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com, Edward Liaw Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Android this test is getting stuck in an infinite loop due to indeterminate behavior: The local variables steps and signalled were being reset to 1 and 0 respectively after every jump back to sigsetjmp by siglongjmp in the signal handler. The test was incrementing them and expecting them to retain their incremented values. The documentation for siglongjmp says: All accessible objects have values as of the time sigsetjmp() was called, except that the values of objects of automatic storage duration which are local to the function containing the invocation of the corresponding sigsetjmp() which do not have volatile-qualified type and which are changed between the sigsetjmp() invocation and siglongjmp() call are indeterminate. Tagging steps and signalled with volatile enabled the test to pass. Signed-off-by: Edward Liaw --- tools/testing/selftests/vm/userfaultfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 0bdfc1955229..2b2a68722ae1 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -931,7 +931,7 @@ static int faulting_process(int signal_test) unsigned long split_nr_pages; unsigned long lastnr; struct sigaction act; - unsigned long signalled = 0; + volatile unsigned long signalled = 0; split_nr_pages = (nr_pages + 1) / 2; @@ -946,7 +946,7 @@ static int faulting_process(int signal_test) } for (nr = 0; nr < split_nr_pages; nr++) { - int steps = 1; + volatile int steps = 1; unsigned long offset = nr * page_size; if (signal_test) { -- 2.36.1.476.g0c4daa206d-goog