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=-1.1 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 A3CC3C433E1 for ; Tue, 30 Jun 2020 21:30:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6003620775 for ; Tue, 30 Jun 2020 21:30:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EvBygRPn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6003620775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E4A068D0011; Tue, 30 Jun 2020 17:30:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFA098D000F; Tue, 30 Jun 2020 17:30:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0FDC8D0011; Tue, 30 Jun 2020 17:30:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id B92A98D000F for ; Tue, 30 Jun 2020 17:30:15 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4738B1EE6 for ; Tue, 30 Jun 2020 21:30:15 +0000 (UTC) X-FDA: 76987171590.26.pen34_1e0188826e7b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 20F311804B660 for ; Tue, 30 Jun 2020 21:30:15 +0000 (UTC) X-HE-Tag: pen34_1e0188826e7b X-Filterd-Recvd-Size: 5964 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Tue, 30 Jun 2020 21:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593552614; 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=nixTOEgW0Ceg9ragNEY0z/vysduzB+SPEPITIinZzc4=; b=EvBygRPnjpmDPmpA8redaRsVvJ8QOHFTeaUGRtxfzVAVI2NrCQI/kBJnEnvopVX2QheLGD ZEDXYX2cRO4v6so3ixFgmbs1mXO8qI+cRYBu1i6LGBoCNJS2drbdWtKthZoaJQICZFnL0K P4f2gsQdDdcejFQYLcp/6ue3chV+GEk= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-g0Gjnp7qP8SPHVq3r1H20A-1; Tue, 30 Jun 2020 17:30:12 -0400 X-MC-Unique: g0Gjnp7qP8SPHVq3r1H20A-1 Received: by mail-qt1-f200.google.com with SMTP id z26so15373237qto.15 for ; Tue, 30 Jun 2020 14:30:12 -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=nixTOEgW0Ceg9ragNEY0z/vysduzB+SPEPITIinZzc4=; b=cU3EGzFZWVAN2aXP6qgLkrSd6LwZ3DFFAtdb5MwH0scRruwoGQI4+JBteafFQUzLfS vL0gRv+qixzbpgKsZydzqYVCi544OKJSmx29UQ8UN0t+5xk2fis5G4tgZLAtG6Wo3F07 7fJOC1gb5FKhwf3aXRyjaYyqicNIuZ81biNndFzYwiNytvr8UUj6khjrwz8BJhpONwea VRsOiWpArWAY3g+Cb9i4TYF8681UQVS0EjmjthKZRzA/tMbI1i1KlXYPRk6TWVvIiXac hrsXW9mkP5dTxI/iqBQR0qjgg3IlIESH8yHMJkpeZHP1o4eO6F1l2VeIlAltjn9rQfPo U1eQ== X-Gm-Message-State: AOAM533s0Cgv45sAINsrz4ueb6wXcD0MtFsJswRb7ybyIfX2RZdcbHr5 ft1ER+ecenMzWzEchEawb3hdEo0WPw1bemM9G4w8HKzO4Q+F+oY61y/fqIdCCMTpplwkR+U6L5c 7k7ZobBqdABY= X-Received: by 2002:a0c:b520:: with SMTP id d32mr21988722qve.6.1593552611742; Tue, 30 Jun 2020 14:30:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr4obTuj/cs4C2lP57Bc/3hny00QnJmyUX9M22AqhyXRRhcvUT43X97TBWfW0aa3cCoD4fGA== X-Received: by 2002:a0c:b520:: with SMTP id d32mr21988692qve.6.1593552611371; Tue, 30 Jun 2020 14:30:11 -0700 (PDT) Received: from xz-x1 ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id t48sm4416862qtb.50.2020.06.30.14.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 14:30:10 -0700 (PDT) Date: Tue, 30 Jun 2020 17:30:09 -0400 From: Peter Xu To: David Rientjes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , John Hubbard , Michael Ellerman , Gerald Schaefer , Andrea Arcangeli , Linus Torvalds , Will Deacon Subject: Re: [PATCH v4 01/26] mm: Do page fault accounting in handle_mm_fault Message-ID: <20200630213009.GB40675@xz-x1> References: <20200630204504.38516-1-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: 20F311804B660 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: Hi, David, On Tue, Jun 30, 2020 at 02:05:24PM -0700, David Rientjes wrote: > On Tue, 30 Jun 2020, Peter Xu wrote: > > > @@ -4408,6 +4440,34 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address, > > mem_cgroup_oom_synchronize(false); > > } > > > > + if (ret & (VM_FAULT_RETRY | VM_FAULT_ERROR)) > > + return ret; > > + > > + /* > > + * Do accounting in the common code, to avoid unnecessary > > + * architecture differences or duplicated code. > > + * > > + * We arbitrarily make the rules be: > > + * > > + * - Unsuccessful faults do not count (e.g. when the address wasn't > > + * valid). That includes arch_vma_access_permitted() failing above. > > + * > > + * So this is expressly not a "this many hardware page faults" > > + * counter. Use the hw profiling for that. > > + * > > + * - Incomplete faults do not count (e.g. RETRY). They will only > > + * count once completed. > > + * > > + * - The fault counts as a "major" fault when the final successful > > + * fault is VM_FAULT_MAJOR, or if it was a retry (which implies that > > + * we couldn't handle it immediately previously). > > + * > > + * - If the fault is done for GUP, regs will be NULL and no accounting > > + * will be done. > > + */ > > + mm_account_fault(regs, address, (ret & VM_FAULT_MAJOR) || > > + (flags & FAULT_FLAG_TRIED)); > > + > > return ret; > > } > > EXPORT_SYMBOL_GPL(handle_mm_fault); > > Just a nit, likely not important: I wonder if it would be cleaner to pass > the vm_fault_t into mm_account_fault() and then do the VM_FAULT_RETRY and > VM_FAULT_ERROR checks there as well as putting the comment about how > accounting is handled in that function. Your comment is great. Yes that seems to be cleaner so handle_mm_fault is shorter (btw, I "stole" the comment block majorly from Linus :). But this change will also need to touch patch 25 again or it won't apply cleanly. So I think I'll see whether Andrew would like me to repost the whole series then I'll adopt the change when I repost, or another alternative is maybe we can also do that on top, depending on whether there's further comments.. Thanks! -- Peter Xu