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 X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2760AC433E0 for ; Mon, 15 Jun 2020 21:34:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05DFB207DD for ; Mon, 15 Jun 2020 21:34:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Qq9hJmDA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731665AbgFOVer (ORCPT ); Mon, 15 Jun 2020 17:34:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41508 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731540AbgFOVer (ORCPT ); Mon, 15 Jun 2020 17:34:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592256886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ItwxuioZVdA5XdCXR1QbAewm4+8qdb0KbH1lb+9ehrA=; b=Qq9hJmDAFSNbT0dxqko+g5j+VdL+eMmI9uhGXBbnrSRcb2Iu1Q7FxYb+KZe3t+FoW1W9su tTwKTp/dmNCQNsJuo1aFYOTOK0vDgEnYFDvK9XWMxO6Efe0fqMWnM/Bon/XCJi9+Rb3/fn 9tgmR+X8hTs2HPXnk8zu4wywZG7DJc0= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-407-vXNf6Wz9M4W_OCPXfzSMtA-1; Mon, 15 Jun 2020 17:34:34 -0400 X-MC-Unique: vXNf6Wz9M4W_OCPXfzSMtA-1 Received: by mail-qv1-f72.google.com with SMTP id s15so14024859qvo.6 for ; Mon, 15 Jun 2020 14:34:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ItwxuioZVdA5XdCXR1QbAewm4+8qdb0KbH1lb+9ehrA=; b=bbapbaIobuRPWVi/DjkkZ5xZ41/44fX1LES81OYTjoY+9vOsCnfasDaZA5kcCHjWg4 xeWjUq2YzyXseMaDOyOmUnZF9fT0lleMKhfp7Qu1QbI+q6N46+bZ0dY/ci/7ZyX/6pL+ JpiBbyc0T5pW3YRWQKhXoutQiFaX92gONes9WWlI2N4Q5xNXU1f5r9SfdPSBFm2X4GDX N3+soNZGl6btrZl5pYJzR3KTbyTUY06pmoh7MfGuyU6dYfXiu+2R2q8gWlGZ7IIK1aAO MBZMYQlIh+uYdj1ZKHK4G7u+JmoJJaS6diLTlPTFYe8NNxLloEFvmGKyJ53zw8ekXWcF 50aA== X-Gm-Message-State: AOAM530Yp3JH9LXULY7QoGagH1lUXzl8/9JYJxt5X4Gl2mw8PMU6+iSF CLJka8d+WK39LUYDyyt5lBpQkcwLlhvr8HauEHKZC9WW8mWlWzjCHI+R4AusdLqQHAkgz5wRbVB U9crBVrzLLk9HhLQdlnGyPQ== X-Received: by 2002:a0c:ed31:: with SMTP id u17mr25540583qvq.117.1592256874112; Mon, 15 Jun 2020 14:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0iHGiHde51cucRTUPE7NzfM/1jQRbNlFV4ChXmFExBXup/Ay4TPRKGywEeToUwHIWcL2Psg== X-Received: by 2002:a0c:ed31:: with SMTP id u17mr25540552qvq.117.1592256873805; Mon, 15 Jun 2020 14:34:33 -0700 (PDT) Received: from xz-x1 ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id f30sm12961493qtb.9.2020.06.15.14.34.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 14:34:33 -0700 (PDT) Date: Mon, 15 Jun 2020 17:34:31 -0400 From: Peter Xu To: Gerald Schaefer Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , linux-mips@vger.kernel.org, Nick Hu , Ley Foon Tan , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, Guan Xuetao , linux-xtensa@linux-xtensa.org, Heiko Carstens , Linus Torvalds , Andrea Arcangeli Subject: Re: Possible duplicate page fault accounting on some archs after commit 4064b9827063 Message-ID: <20200615213431.GC111927@xz-x1> References: <20200610174811.44b94525@thinkpad> <20200610165023.GA67179@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200610165023.GA67179@xz-x1> Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Wed, Jun 10, 2020 at 12:50:23PM -0400, Peter Xu wrote: > On Wed, Jun 10, 2020 at 05:48:11PM +0200, Gerald Schaefer wrote: > > Hi, > > Hi, Gerald, > > > > > Some architectures have their page fault accounting code inside the fault > > retry loop, and rely on only going through that code once. Before commit > > 4064b9827063 ("mm: allow VM_FAULT_RETRY for multiple times"), that was > > ensured by testing for and clearing FAULT_FLAG_ALLOW_RETRY. > > > > That commit had to remove the clearing of FAULT_FLAG_ALLOW_RETRY for all > > architectures, and introduced a subtle change to page fault accounting > > logic in the affected archs. It is now possible to go through the retry > > loop multiple times, and the affected archs would then account multiple > > page faults instead of just one. > > > > This was found by coincidence in s390 code, and a quick check showed that > > there are quite a lot of other architectures that seem to be affected in a > > similar way. I'm preparing a fix for s390, by moving the accounting behind > > the retry loop, similar to x86. It is not completely straight-forward, so > > I leave the fix for other archs to the respective maintainers. > > Sorry for not noticing this before. The accounting part should definitely be > put at least into a check against fault_flag_allow_retry_first() to mimic what > was done before. And I agree it would be even better to put it after the retry > logic, so if any of the page faults gets a major fault, it'll be accounted as a > major fault which makes more sense to me, just like what x86 is doing now with: > > major |= fault & VM_FAULT_MAJOR; > > I'm not sure what's the preference of the arch maintainers, just let me know if > it's preferred to use a single series to address this issue for all affected > archs (or the archs besides s390), then I'll do. To make sure this won't fall through the cracks... I'll give it a shot with a single series to address this issue for all archs. Although it might not be easy to do accounting directly in handle_mm_fault(), it might be still a chance to introduce a helper so the accounting can be done in general code. Thanks, -- Peter Xu