Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp354061pxb; Wed, 14 Apr 2021 17:37:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5/8PwN/+UPz5VlzMFdHdgirSfig9Q9r+a9b42nkE5w3Ifd9vK8f3dEjl+TvUXxtMlLsEE X-Received: by 2002:a05:6402:8:: with SMTP id d8mr969986edu.368.1618447024099; Wed, 14 Apr 2021 17:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447024; cv=none; d=google.com; s=arc-20160816; b=ZPIWbIq+SQjHvJ2XLvgvk7modXYPnTFFYK56WNvfHOIjUhkT3J6NLOBmyeZWIQBdBZ dj7QC069QjOCdz+cfw33BgJ2qIxCeAl3o9aI5UEBlrUpvUxaWK/5nBTcRYTsIUOUu/tu DyDDwfX9w9NIlAHuAOlh2DKVJ8nnq6R9fX8fh+Av/5XslAzQlK/7YPBwsvt/nqW3Qb2l Iv+swLBnDTqC826ervpJypyDXQAAbAvxzT+rqu8l76Rm8MB5exBMYh+yi3e5VlsjxGIL YKNllay8oO+o85aTQApLxEwxVYE5zmTysZZP4MRL4MwkPBMoeDZNDDUp7AqpJGw2HhYo gxLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=927x1OxFGjZhXg2hFqKXGTiskEIk6MxUpR4SI4f8vSc=; b=UmYywyYyz+B+cGalw1QFAfs71DOqXCD4PW2IdVRPC/f7AEVgGZMWf1GQIXSVrac92K xXjU4eXqxn+q7boJz1XdTIXl1uz27eDJ9W7asYuyWHm/zolKKYPcelP+U1LGEBirjsa5 1BWI6MFrV89JxffwXoAlL7ovBql/rmDYZmklFZD1OOrIxhlWny6DmiyShMXtlN6mWKLS 6egXmKCYTpKhmKUd6JFYVe5ICk8gNHmfBcjX5cGIh6Te9tEZaekxSERveLf+aBQdnZbC +wq+8zZHGtpXNpsHzZZt7cw+hKGDdHvyzqMoHFErwZsyR4ml+2L3IvdDAKqUVNA2vF+r 70Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W5f7+Duy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si926955edx.149.2021.04.14.17.36.41; Wed, 14 Apr 2021 17:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W5f7+Duy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232604AbhDNRJv (ORCPT + 99 others); Wed, 14 Apr 2021 13:09:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58421 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbhDNRJu (ORCPT ); Wed, 14 Apr 2021 13:09:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618420168; 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: in-reply-to:in-reply-to:references:references; bh=927x1OxFGjZhXg2hFqKXGTiskEIk6MxUpR4SI4f8vSc=; b=W5f7+DuyfPixkrpUJJqMOqEKUQ20dt1N1sVQQlXkgZOD9i2/OXkJLHIrMl5iSZ+8maTHzN rLUSucmvKu/2u6DLBs40UG+JGegu/ZBysmeVCnOOYW3bzhOsUz1fvIMb74NqNwmV8KyFDj MSUEtgEwt4EikhvjTladlWY5GHGLTJ8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-DLv3OehOMWuiZSgOgEctCg-1; Wed, 14 Apr 2021 13:09:24 -0400 X-MC-Unique: DLv3OehOMWuiZSgOgEctCg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9479C6D241; Wed, 14 Apr 2021 17:09:21 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.65]) by smtp.corp.redhat.com (Postfix) with SMTP id A382E5D6A8; Wed, 14 Apr 2021 17:09:16 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 14 Apr 2021 19:09:21 +0200 (CEST) Date: Wed, 14 Apr 2021 19:09:15 +0200 From: Oleg Nesterov To: Andrei Vagin Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-um@lists.infradead.org, criu@openvz.org, avagin@google.com, Andrew Morton , Andy Lutomirski , Anton Ivanov , Christian Brauner , Dmitry Safonov <0x7f454c46@gmail.com>, Ingo Molnar , Jeff Dike , Mike Rapoport , Michael Kerrisk , Peter Zijlstra , Richard Weinberger , Thomas Gleixner Subject: Re: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall Message-ID: <20210414170915.GB22294@redhat.com> References: <20210414055217.543246-1-avagin@gmail.com> <20210414055217.543246-3-avagin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210414055217.543246-3-avagin@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/13, Andrei Vagin wrote: > > +static void swap_mm(struct mm_struct *prev_mm, struct mm_struct *target_mm) > +{ > + struct task_struct *tsk = current; > + struct mm_struct *active_mm; > + > + task_lock(tsk); > + /* Hold off tlb flush IPIs while switching mm's */ > + local_irq_disable(); > + > + sync_mm_rss(prev_mm); > + > + vmacache_flush(tsk); > + > + active_mm = tsk->active_mm; > + if (active_mm != target_mm) { > + mmgrab(target_mm); > + tsk->active_mm = target_mm; > + } > + tsk->mm = target_mm; > + switch_mm_irqs_off(active_mm, target_mm, tsk); > + local_irq_enable(); > + task_unlock(tsk); > +#ifdef finish_arch_post_lock_switch > + finish_arch_post_lock_switch(); > +#endif > + > + if (active_mm != target_mm) > + mmdrop(active_mm); > +} I think this should be unified with kthread_use_mm() somehow... And does it really need the "prev_mm" argument? It must be tsk->mm, no? Oleg.