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=-10.1 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL 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 D91F2C433E1 for ; Tue, 30 Jun 2020 21:05:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7FF552053B for ; Tue, 30 Jun 2020 21:05:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QUdibEW+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FF552053B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B6D826B0096; Tue, 30 Jun 2020 17:05:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1CA76B0099; Tue, 30 Jun 2020 17:05:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A325F6B009A; Tue, 30 Jun 2020 17:05:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0219.hostedemail.com [216.40.44.219]) by kanga.kvack.org (Postfix) with ESMTP id 8CE296B0096 for ; Tue, 30 Jun 2020 17:05:29 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 364D7180AD804 for ; Tue, 30 Jun 2020 21:05:29 +0000 (UTC) X-FDA: 76987109178.02.wheel26_5a128fd26e7b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 99A2710009BB9920 for ; Tue, 30 Jun 2020 21:05:28 +0000 (UTC) X-HE-Tag: wheel26_5a128fd26e7b X-Filterd-Recvd-Size: 4931 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Tue, 30 Jun 2020 21:05:28 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id l6so6926564pjq.1 for ; Tue, 30 Jun 2020 14:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=7IVzLJAup4VkDuAt/OunGpXP5pyiE7ynN3kodoEoQWE=; b=QUdibEW+tmy14fhQZz/MEX47zW5zuODLO2iw5hCK+fuz6atzNqZS7wfwq88aa5gGNZ tcoL4SeyvbY2vZmuDYF3SJACAtGQNg2IUJvfpnMncjKaqSpG+Ag8Up58cx+CC5r0x0by oWkkAUayol9EAh71nHOO/Cyzkwxn0qRfwv8rIwAUjTLk55vymD83jgXIJjUjDplKPxzQ twNxTc0A2bK/TrTAepZMJ8yD2igZBAP5033cejEg5xi9B5nra3awyGB6anyEkxBLnPth xMLNrjI0kueaOX2OFYgDwPamPjl7Tj5L+9O1YReWNl93rCB3emRFthqAk9voQHii1UyL 1iLQ== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=7IVzLJAup4VkDuAt/OunGpXP5pyiE7ynN3kodoEoQWE=; b=hFJVtQrzP3autnKsrjE5mp4p8Aa6+ST0io/nAYCB81G3nkPmKb8wO1/X+WwZgAaH0s iDudXWEY5ySRT2XVA0JXd/i6JZL/FBK0nCB7oGI18Knyq3KqeUFpZi/CCtymwvb5BM1K 8o0KH7R7vrWkcgSVclugVmZs9KYRQJBghcBlOFvIIhqJrv1jAekjY9IuEepibKtgLYDJ IcBlcnnxdf6/iSKo2vlTqRzTf8zhfBqajcDWJF6uIQ80iKnfb/KVOHdQWKDfKlNcnssA wU71fsm5nIWHKdWM/f93+9h0vmFaH7D3wlncwpJpJ6dJ2Iicn9lHdNQ/FWF7N+/pqUi6 zlxw== X-Gm-Message-State: AOAM530TPMxVh2X/IMqILb51z4ai+vOJEF0KYGcYWtnBtIaQLSK4BmsW 3KQjDBwE8J3lyWDQ+hM63XQF0g== X-Google-Smtp-Source: ABdhPJyq5YmJisNfnjQfOl9rdHWGw5ke+qYQHvoo0zgIGiWy+mH4xpMMFhE4xTloPrHRDSCSwy44xw== X-Received: by 2002:a17:90a:db0f:: with SMTP id g15mr23799623pjv.5.1593551125958; Tue, 30 Jun 2020 14:05:25 -0700 (PDT) Received: from [2620:15c:17:3:4a0f:cfff:fe51:6667] ([2620:15c:17:3:4a0f:cfff:fe51:6667]) by smtp.gmail.com with ESMTPSA id h100sm3168311pjb.46.2020.06.30.14.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 14:05:24 -0700 (PDT) Date: Tue, 30 Jun 2020 14:05:24 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Peter Xu 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 In-Reply-To: <20200630204504.38516-1-peterx@redhat.com> Message-ID: References: <20200630204504.38516-1-peterx@redhat.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 99A2710009BB9920 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: 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.