From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933396AbcE3Pef (ORCPT ); Mon, 30 May 2016 11:34:35 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:43035 "EHLO e33.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932508AbcE3Pee (ORCPT ); Mon, 30 May 2016 11:34:34 -0400 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: aneesh.kumar@linux.vnet.ibm.com X-IBM-RcptTo: hillf.zj@alibaba-inc.com;linux-mm@kvack.org;linux-kernel@vger.kernel.org From: "Aneesh Kumar K.V" To: Hillf Danton Cc: linux-kernel , linux-mm@kvack.org Subject: Re: [RFC PATCH 2/4] mm: Change the interface for __tlb_remove_page In-Reply-To: <001901d1ba4a$514eccc0$f3ec6640$@alibaba-inc.com> References: <001701d1ba44$b9c0d560$2d428020$@alibaba-inc.com> <001901d1ba4a$514eccc0$f3ec6640$@alibaba-inc.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Mon, 30 May 2016 21:04:27 +0530 Message-ID: <87mvn71rwc.fsf@skywalker.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16053015-0009-0000-0000-000037DBFBB0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hillf Danton writes: >> diff --git a/mm/memory.c b/mm/memory.c >> index 15322b73636b..a01db5bc756b 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -292,23 +292,24 @@ void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long e >> * handling the additional races in SMP caused by other CPUs caching valid >> * mappings in their TLBs. Returns the number of free page slots left. >> * When out of page slots we must call tlb_flush_mmu(). >> + *returns true if the caller should flush. >> */ >> -int __tlb_remove_page(struct mmu_gather *tlb, struct page *page) >> +bool __tlb_remove_page(struct mmu_gather *tlb, struct page *page) >> { >> struct mmu_gather_batch *batch; >> >> VM_BUG_ON(!tlb->end); >> >> batch = tlb->active; >> - batch->pages[batch->nr++] = page; >> if (batch->nr == batch->max) { >> if (!tlb_next_batch(tlb)) >> - return 0; >> + return true; >> batch = tlb->active; >> } >> VM_BUG_ON_PAGE(batch->nr > batch->max, page); > > Still needed? yes, we need to make sure the batch we picked doesn't have a wrong batch->nr value. >> >> - return batch->max - batch->nr; >> + batch->pages[batch->nr++] = page; >> + return false; >> } >> >> #endif /* HAVE_GENERIC_MMU_GATHER */ >> @@ -1109,6 +1110,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, >> pte_t *start_pte; >> pte_t *pte; >> swp_entry_t entry; >> + struct page *pending_page = NULL; >> >> again: >> init_rss_vec(rss); >> @@ -1160,8 +1162,9 @@ again: >> page_remove_rmap(page, false); >> if (unlikely(page_mapcount(page) < 0)) >> print_bad_pte(vma, addr, ptent, page); >> - if (unlikely(!__tlb_remove_page(tlb, page))) { >> + if (unlikely(__tlb_remove_page(tlb, page))) { >> force_flush = 1; >> + pending_page = page; >> addr += PAGE_SIZE; >> break; >> } >> @@ -1202,7 +1205,12 @@ again: >> if (force_flush) { >> force_flush = 0; >> tlb_flush_mmu_free(tlb); >> - >> + if (pending_page) { >> + /* remove the page with new size */ >> + __tlb_adjust_range(tlb, tlb->addr); > > Would you please specify why tlb->addr is used here? > That is needed because tlb_flush_mmu_tlbonly() does a __tlb_reset_range(). >> + __tlb_remove_page(tlb, pending_page); >> + pending_page = NULL; >> + } >> if (addr != end) >> goto again; >> } >> -- >> 2.7.4 -aneesh