Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10901399ybi; Thu, 25 Jul 2019 06:48:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzd1romRL8pGJPI7WaWGXXn+QoYr7YRIndVFfQu8wBNg5hQFqbo1kVRDOhQ7eFEtY17bOAV X-Received: by 2002:a17:90a:1aa4:: with SMTP id p33mr94258257pjp.27.1564062512285; Thu, 25 Jul 2019 06:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564062512; cv=none; d=google.com; s=arc-20160816; b=YGJA1D1J1GGpUa32m8platTfOsYpiuZY6vcxa4FJAaVWeHh+HTHxZETdScFQZfo76x Hrg0U5PMlUwY30Ufi8AvbFXqQ2Go2II93vuvNTkCWC2KLZFiOI2ehI1imRfTsA5dpiqH TJFHv3nlEIq5N+jmk9Lgcwm0ba9GtZ1dJaKg+WhYUgFxwNbRTZSFKZHjY9mjaPu5Tb0Z q8SpDqWrZgahWel3vK+HcbZ9eb7WjkOwRLD2aYALUiDPjEDfkwsY+AoZFb1KgG5DEQZv IO9lUBk5JjzKSP2YDiWembQt0iHBEmxBHU49pr62OUlVT1YFjkhm6P03Y2knV5APJgGP uIDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=i19VkmUA/JjV1baDqjaCUFBUl3HEhx06QA8y1Sjqx2Y=; b=bq/pNcQx5QOnDw+CIZ9VohzgjJAdQi+ikbCQbPIYKSOfo83aMtTShJ1frYrE66TLZT xeJbAeBuOwG0YY1yGgBHPK7Laa50GY96jT/Q9kb9RaX4E+ND2VRd7xeqpQcYDb5RjHjL Qoqo3KVjeRQYybcZD5+OzfiMhraGgSbTmKQnQ/OBTOIpGG56o4zWx1OYHlcx02I8LoAQ VOfQKnZnU3RhGKkjJDDZR2AMIRrmO62oOpdbehK1LQlQeB4hdkVY3F8WwIi5jfayuhFD BgbarjBmpPPezg8RJA2Db+m0jjYSQX66LgCuM+G1mtTJbhxBgV/ELjAtRlOg0SrMhMaN TCjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FY1NJT9V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3si18307825pgl.499.2019.07.25.06.48.18; Thu, 25 Jul 2019 06:48:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FY1NJT9V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404198AbfGYLoK (ORCPT + 99 others); Thu, 25 Jul 2019 07:44:10 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52536 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388154AbfGYLoK (ORCPT ); Thu, 25 Jul 2019 07:44:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=i19VkmUA/JjV1baDqjaCUFBUl3HEhx06QA8y1Sjqx2Y=; b=FY1NJT9VDEPZNIxz3Cx6zp8eE AkhT6C4nMXH4+xI8bgTRfVlXBfYv/c4iwNpHN7E14TH/fPjMP23dDVpoW5UoQPGUloknxIVUUiKf/ 5fAhay9ppAQSPw3QccU0LY31rX1wQtRKb3rscJqLglpgxytDWRZBWANdnLWRFwdLLt5Jwe778enkK UB5erxDzKrkcWYDPYUpcOZxRq5z90AuZZk4n7oaw7YuwZyvaX+SXFbpbrf1ORsKcJORe0F1sXNt1q OWuhktmc6pQaocLPV9QXGyClV2YzweTCDwCV+dV/bN/4ENX6+kOaEK37+gLGnLUzTjCIJ/IwcDaco lUlZavJuQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hqcAK-0000R5-94; Thu, 25 Jul 2019 11:44:08 +0000 Date: Thu, 25 Jul 2019 04:44:08 -0700 From: Matthew Wilcox To: "Huang, Ying" Cc: Mikhail Gavrilov , huang ying , Linux List Kernel Mailing , linux-mm@kvack.org Subject: Re: kernel BUG at mm/swap_state.c:170! Message-ID: <20190725114408.GV363@bombadil.infradead.org> References: <878ssqbj56.fsf@yhuang-dev.intel.com> <87zhl59w2t.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zhl59w2t.fsf@yhuang-dev.intel.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 23, 2019 at 01:08:42PM +0800, Huang, Ying wrote: > @@ -2489,6 +2491,14 @@ static void __split_huge_page(struct page *page, struct list_head *list, > /* complete memcg works before add pages to LRU */ > mem_cgroup_split_huge_fixup(head); > > + if (PageAnon(head) && PageSwapCache(head)) { > + swp_entry_t entry = { .val = page_private(head) }; > + > + offset = swp_offset(entry); > + swap_cache = swap_address_space(entry); > + xa_lock(&swap_cache->i_pages); > + } > + > for (i = HPAGE_PMD_NR - 1; i >= 1; i--) { > __split_huge_page_tail(head, i, lruvec, list); > /* Some pages can be beyond i_size: drop them from page cache */ > @@ -2501,6 +2511,9 @@ static void __split_huge_page(struct page *page, struct list_head *list, > } else if (!PageAnon(page)) { > __xa_store(&head->mapping->i_pages, head[i].index, > head + i, 0); > + } else if (swap_cache) { > + __xa_store(&swap_cache->i_pages, offset + i, > + head + i, 0); I tried something along these lines (though I think I messed up the offset calculation which is why it wasn't working for me). My other concern was with the case where SWAPFILE_CLUSTER was less than HPAGE_PMD_NR. Don't we need to drop the lock and look up a new swap_cache if offset >= SWAPFILE_CLUSTER?