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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DAC4C433EF for ; Tue, 12 Apr 2022 09:37:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1189A6B007D; Tue, 12 Apr 2022 05:37:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C7CD6B007E; Tue, 12 Apr 2022 05:37:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED1DB6B0080; Tue, 12 Apr 2022 05:37:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id E0E7C6B007D for ; Tue, 12 Apr 2022 05:37:15 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id B3AAC121D5E for ; Tue, 12 Apr 2022 09:37:15 +0000 (UTC) X-FDA: 79347723630.03.B7CD52B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 15C8D140002 for ; Tue, 12 Apr 2022 09:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649756234; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QqASKl2JW8OF7//R5gBnGu+2jzFwc031nNCcqeSxD8M=; b=SJWAsD8lagWUVEiqxkzo3TkCfcqeq/Y6xsSKvuVUmOBRjhzt22F4W3HnJwvLh6k7mpRLLC OUDKkmL7yig341SkVRbY5aZi0Q9R+XE1b2qDPBHV/D4UvFKe0QdKYKmB+pMQ86PUlR7Nzz 8bOxkjn1momgD2sQ5BTyb6awYSfRna0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-503--z-155smPF2dueRORLbp7Q-1; Tue, 12 Apr 2022 05:37:13 -0400 X-MC-Unique: -z-155smPF2dueRORLbp7Q-1 Received: by mail-wr1-f69.google.com with SMTP id t15-20020adfdc0f000000b001ef93643476so3858642wri.2 for ; Tue, 12 Apr 2022 02:37:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=QqASKl2JW8OF7//R5gBnGu+2jzFwc031nNCcqeSxD8M=; b=63gcwVIs9iZQzr8epLo2LWQvncvTf+IZzxDJZHhfBqLiZcQMhDiJ7qstNTtQ0ImFJJ ij0m7yiAn1i2zJmrZb5UvsOMPAKgLSMc470skAwFX63d5FRaU6y8upaAFhz1nwt2sOfo hXgTl0HOxbcxEtw4XNWremSwa2sjaRdThLk/uaIDYTOdSqOxWFLjBDjeKojovz53v3vg bE/FGrSM+KIH1TCe1FQKjeRy5AhMj6+QDYiqoIHyKNo/QIvgk4SApKrv/vT0YX7XCBQD +Bo5qnjkB+slwGJDJqZiCIzY5WCwwuxwpO7AljEoZn7wJ3G0NF8nDLxW7B+SLXhmUjac ywrg== X-Gm-Message-State: AOAM532Ikdicm0IoFCaA1pLlubCF3/6YmcOJxWis+y1JzSDUTDfICPpg 7bIy736A6ELvYFb7REQUvroPhFvGqEr+OE9kma89rFN/tm5ZbhxrCyc7O0xYykGlfBFRpdIdyUI /zZCPICZxtT4= X-Received: by 2002:a05:600c:1f17:b0:38b:b2b3:9faa with SMTP id bd23-20020a05600c1f1700b0038bb2b39faamr3334633wmb.190.1649756231976; Tue, 12 Apr 2022 02:37:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFdKjiRGvmX5jcrTl/ai7AaND7+BndRgIvrorg6KZ5vxUMxir/XkgirRzWpwcfBCleZLlw0A== X-Received: by 2002:a05:600c:1f17:b0:38b:b2b3:9faa with SMTP id bd23-20020a05600c1f1700b0038bb2b39faamr3334613wmb.190.1649756231691; Tue, 12 Apr 2022 02:37:11 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:1800:7c14:16cc:5291:a9f3? (p200300cbc70718007c1416cc5291a9f3.dip0.t-ipconnect.de. [2003:cb:c707:1800:7c14:16cc:5291:a9f3]) by smtp.gmail.com with ESMTPSA id g1-20020a5d64e1000000b002079b871795sm9059647wri.50.2022.04.12.02.37.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Apr 2022 02:37:11 -0700 (PDT) Message-ID: <368902ab-8d3f-5d62-581e-1ff930bcefa0@redhat.com> Date: Tue, 12 Apr 2022 11:37:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH v3 08/16] mm/rmap: drop "compound" parameter from page_add_new_anon_rmap() To: Vlastimil Babka , linux-kernel@vger.kernel.org Cc: Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , linux-mm@kvack.org References: <20220329160440.193848-1-david@redhat.com> <20220329160440.193848-9-david@redhat.com> <4cb92b41-95e1-1666-321e-96ff9e6095bb@suse.cz> From: David Hildenbrand Organization: Red Hat In-Reply-To: <4cb92b41-95e1-1666-321e-96ff9e6095bb@suse.cz> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 15C8D140002 X-Stat-Signature: diawof3ggkg18btn43k5se7kf7q1ihdw Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SJWAsD8l; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf09.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspam-User: X-HE-Tag: 1649756234-780856 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 12.04.22 10:47, Vlastimil Babka wrote: > On 3/29/22 18:04, David Hildenbrand wrote: >> New anonymous pages are always mapped natively: only THP/khugepagd code > > khugepaged ^ > >> maps a new compound anonymous page and passes "true". Otherwise, we're >> just dealing with simple, non-compound pages. >> >> Let's give the interface clearer semantics and document these. >> >> Signed-off-by: David Hildenbrand > > Acked-by: Vlastimil Babka > > Nit: > >> --- a/mm/rmap.c >> +++ b/mm/rmap.c >> @@ -1182,19 +1182,22 @@ void page_add_anon_rmap(struct page *page, >> } >> >> /** >> - * page_add_new_anon_rmap - add pte mapping to a new anonymous page >> + * page_add_new_anon_rmap - add mapping to a new anonymous page >> * @page: the page to add the mapping to >> * @vma: the vm area in which the mapping is added >> * @address: the user virtual address mapped >> - * @compound: charge the page as compound or small page >> + * >> + * If it's a compound page, it is accounted as a compound page. As the page >> + * is new, it's assume to get mapped exclusively by a single process. >> * >> * Same as page_add_anon_rmap but must only be called on *new* pages. >> * This means the inc-and-test can be bypassed. >> * Page does not have to be locked. >> */ >> void page_add_new_anon_rmap(struct page *page, >> - struct vm_area_struct *vma, unsigned long address, bool compound) >> + struct vm_area_struct *vma, unsigned long address) >> { >> + const bool compound = PageCompound(page); >> int nr = compound ? thp_nr_pages(page) : 1; >> >> VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma); > > There's a VM_BUG_ON_PAGE(PageTransCompound(page), page); later in a > !compound branch. Since compound is now determined by the same check, could > be deleted. > Yes, eventually we could get rid of both VM_BUG_ON_PAGE() on both branches and add a single VM_BUG_ON_PAGE(PageTail(page), page) check on the compound branch. (we could also make sure that we're not given a hugetlb page) -- Thanks, David / dhildenb