Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751168AbdFBILS (ORCPT ); Fri, 2 Jun 2017 04:11:18 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42798 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751130AbdFBILM (ORCPT ); Fri, 2 Jun 2017 04:11:12 -0400 Date: Fri, 2 Jun 2017 10:11:05 +0200 From: Martin Schwidefsky To: Christian Borntraeger Cc: Heiko Carstens , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Huth Subject: Re: [PATCH RFC 0/2] KVM: s390: avoid having to enable vm.alloc_pgste In-Reply-To: References: <20170529163202.13077-1-david@redhat.com> <20170601124651.3e7969ab@mschwideX1> <20170602070210.GA4221@osiris> <20170602091638.5583cfb2@mschwideX1> <787556bd-2c20-48e8-edd4-f4c5c5a5eaaf@de.ibm.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17060208-0040-0000-0000-000003BFF682 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060208-0041-0000-0000-000020555906 Message-Id: <20170602101105.11e7fd2c@mschwideX1> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-02_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706020153 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2893 Lines: 63 On Fri, 2 Jun 2017 09:25:54 +0200 Christian Borntraeger wrote: > On 06/02/2017 09:18 AM, Christian Borntraeger wrote: > > On 06/02/2017 09:16 AM, Martin Schwidefsky wrote: > >> On Fri, 2 Jun 2017 09:13:03 +0200 > >> Christian Borntraeger wrote: > >> > >>> On 06/02/2017 09:02 AM, Heiko Carstens wrote: > >>>> On Thu, Jun 01, 2017 at 12:46:51PM +0200, Martin Schwidefsky wrote: > >>>>>> Unfortunately, converting all page tables to 4k pgste page tables is > >>>>>> not possible without provoking various race conditions. > >>>>> > >>>>> That is one approach we tried and was found to be buggy. The point is that > >>>>> you are not allowed to reallocate a page table while a VMA exists that is > >>>>> in the address range of that page table. > >>>>> > >>>>> Another approach we tried is to use an ELF flag on the qemu executable. > >>>>> That does not work either because fs/exec.c allocates and populates the > >>>>> new mm struct for the argument pages before fs/binfmt_elf.c comes into > >>>>> play. > >>>> > >>>> How about if you would fail the system call within arch_check_elf() if you > >>>> detect that the binary requires pgstes (as indicated by elf flags) and then > >>>> restart the system call? > >>>> > >>>> That is: arch_check_elf() e.g. would set a thread flag that future mm's > >>>> should be allocated with pgstes. Then do_execve() would cleanup everything > >>>> and return to entry.S. Upon return to userspace we detect this condition > >>>> and simply restart the system call, similar to signals vs -ERESTARTSYS. > >>>> > >>>> That would make do_execve() cleanup everything and upon reentering it would > >>>> allocate an mm with the pgste flag set. > >>>> > >>>> Maybe this is a bit over-simplified, but might work. > >>>> > >>>> At least I also don't like the next "hack", that is specifically designed > >>>> to only work with how QEMU is currently implemented. It might break with > >>>> future QEMU changes or the next user space implementation that drives the > >>>> kvm interface, but is doing everything differently. > >>>> Let's look for a "clean" solution that will always work. We had too many > >>>> hacks for this problem and *all* of them were broken. > >>> > >>> > >>> The more I think about it, dropping 2k page tables and always allocate a full > >>> page would simplify pgalloc. As far I can see this would also get rid of > >>> the &mm->context.pgtable_lock. > >> > >> And it would waste twice the amount of memory for page tables. NAK. > > > > Yes and we spend the same amount of memory TODAY, because every distro on the > > planet that uses KVM has sysctl.allocate_pgste set. > > Maybe todays approach might be still the best. (if qemu is installed, its all > 4k, if not its all 2k) Exactly- -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.