Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3883987imm; Mon, 17 Sep 2018 04:56:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdasVjvLAXCOP1I/FoVAhDfgp3pL2rRSmz1gdg4WK1z+1zXT9rLjruDdnVoG63NobPUWiZlP X-Received: by 2002:a17:902:968d:: with SMTP id n13-v6mr24623795plp.33.1537185412086; Mon, 17 Sep 2018 04:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537185412; cv=none; d=google.com; s=arc-20160816; b=NzxzeS9QxbaSiRa2Q6UFqNNCW8Nw7gRQRycazZWL+7pZ7PULE8nyvH+N4fRzhWHH5K /FhKII3ATgOcQqSBiiXx2a/AwpW9BnD6Fe15jxAdUCLC1jMHBQWd+oJREZmoVHi+dr2e ZHDWE8dprWkiulIvKBXYsWe4S6K5zak5mFveHMMMGq2CwFdIEJaVyU27wQpOpXqxYaxV WyhQG7+ts2SFT71hTAbK3DQlA0CS9lGj4554Eo6Su4M87tDbBG/K4XvpmMJE/pTc1bEi RO7XN2uVPk9ZK7ziEMlmCDxI3MapbhKK4SAmWEaKYD8gLVczicn/0eISWNaDerdaZt9s 5CdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=C3bSki2yN/h8jeM9zWKULZALvkJObqmJwVTpdghaOXU=; b=HEqsCrK8tqOJdvw/Xfl0bNiTtuZllx/lso4si4ikN7qOs7hAjiUTvVb7wFHBq4ij9u qWekhsT+lbvnfbaQOlRi0ZeWOu9RrGyAE2yxHkejWkvCxq7aSdUhFygIIsP0lpY0AUYT JZJh5afGK4lkF3f8w1HqfAtwkueFpsknX7gEZtdszzDndzJTStTt1Pl5ckx0yGejtPIG 24VIJFEblioBJO+xEXP+b73GHUuT8RwcWv+YAjb/w27nRsP48WlnpA+yBCImoFTLESgC KKSyK1mF5Pga957DFmrAVinmoEZ8WvXtebGHVIoyknPPp3P/HIMKKqUdlgzaG0j/hOAD jztA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZHQuCzHh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9-v6si16492312pfk.166.2018.09.17.04.56.36; Mon, 17 Sep 2018 04:56:52 -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=pass header.i=@gmail.com header.s=20161025 header.b=ZHQuCzHh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728410AbeIQRWj (ORCPT + 99 others); Mon, 17 Sep 2018 13:22:39 -0400 Received: from mail-ua1-f67.google.com ([209.85.222.67]:33843 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728279AbeIQRWj (ORCPT ); Mon, 17 Sep 2018 13:22:39 -0400 Received: by mail-ua1-f67.google.com with SMTP id r15-v6so10313507uao.1 for ; Mon, 17 Sep 2018 04:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C3bSki2yN/h8jeM9zWKULZALvkJObqmJwVTpdghaOXU=; b=ZHQuCzHhoBjDd3cv0yPKvh19YWIQD3TyIn4qKIgcyZfwmEaNB94+NSA84CNgWjQTw7 YzoS0UeLaqBa10NFzXQaazf0z6WNHFBWjYx0hog0ybYCKDcU/K9OsbV4u4kDhIYZ+eLn Eg5a7NWgUmdeZu+Kf3scM/jp2ITqOEGaU+ZFwK5HZw8aBVdu5vfokF0EmoEaVTG9RSji ANI1HnGkJnqgJfQq/NZzXhDLTPH+gRuQnHzmL0LPl9HBu41fDb35lKRLTaNdZ2sEr3tY QEDwrZVpObhR0MWVTuqUPaxr7WVfHZ4zDK9B1l+yJIZWk72hWSdN86X2wYrfVXGbpQ3D xTGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C3bSki2yN/h8jeM9zWKULZALvkJObqmJwVTpdghaOXU=; b=b9GT0Byo10eKsVSMXRLKW7Bcra/tMJp08YN103rhbZcMDA+8dIlGAOPI37NM6wZ9+M F+y8cayZ153SeKpgG9tWuliVo39kJ+HGgeth8RCLnUe5bryNMQWUWDI4PPlkEBISWq5P C8w5wAZDaMShIRqDCrRSBlW8FXLXJctQhO/tFkf42EKGwXkONOj/deGUDWcO+cz2A0tX XXrJDp7cMYksVrnsLEeJ0hCu6rQjd7aiy5EwlE4Zor/D838ZH/I2rkycoWtP+eUbIEaB Hqr8cYYvhNOrnf7ICvDQPQhd5Bf6wWdLWpf2VX12CRpUQz2JuIiFHpTjlDnfkHdbZqTb mokw== X-Gm-Message-State: APzg51DiYp4P19JpnyWitY9tJsDxfszhXHplsykK7ydEYKR5H5a2cyGv A5Sfny5dAhhenfBpwwc6hcMCIykEVzMdhHDCtf0= X-Received: by 2002:ab0:4fda:: with SMTP id t26-v6mr7295798uah.1.1537185338604; Mon, 17 Sep 2018 04:55:38 -0700 (PDT) MIME-Version: 1.0 References: <20180916153237.GC15699@rapoport-lnx> <20180917043724.GA12866@rapoport-lnx> In-Reply-To: From: Pintu Kumar Date: Mon, 17 Sep 2018 17:25:27 +0530 Message-ID: Subject: Re: KSM not working in 4.9 Kernel To: rppt@linux.vnet.ibm.com Cc: open list , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 17, 2018 at 11:46 AM Pintu Kumar wrote: > > > But still no effect. > > > And I checked LTP test cases. It almost doing the same thing. > > > > > > I observed that [ksmd] thread is not waking up at all. > > > I gave some print inside it, but I could never saw that prints coming. > > > I could not find it running either in top command during the operation. > > > Is there anything needs to be done, to wakw up ksmd? > > > I already set: echo 1 > /sys/kernel/mm/ksm. > > > > It should be echo 1 > /sys/kernel/mm/ksm/run > > > > Oh yes, sorry for the typo. > I tried the same, but still ksm is not getting invoked. > Could someone confirm if KSM was working in 4.9 kernel? > Ok, it's working now. I have to explicitly stop the ksm thread to see the statistics. Also there was some internal patch that was setting vm_flags to VM_MERGABLE thus causing ksm_advise call to return. # echo 1 > /sys/kernel/mm/ksm/run # ./malloc-test.out & # echo 0 > /sys/kernel/mm/ksm/run ~ # grep -H '' /sys/kernel/mm/ksm/* /sys/kernel/mm/ksm/full_scans:105 /sys/kernel/mm/ksm/pages_shared:1 /sys/kernel/mm/ksm/pages_sharing:999 /sys/kernel/mm/ksm/pages_to_scan:100 /sys/kernel/mm/ksm/pages_unshared:0 /sys/kernel/mm/ksm/pages_volatile:0 /sys/kernel/mm/ksm/run:0 /sys/kernel/mm/ksm/sleep_millisecs:20 However, I have one doubt. Is the above data correct, for the below program? int main(int argc, char *argv[]) { int i, n, size, ret; char *buffer; void *addr; n = 10; size = 100 * getpagesize(); for (i = 0; i < n; i++) { buffer = (char *)malloc(size); memset(buffer, 0xff, size); madvise(buffer, size, MADV_MERGEABLE); addr = mmap(NULL, size, PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); memset(addr, 0xff, size); ret = madvise(addr, size, MADV_MERGEABLE); if (ret < 0) { fprintf(stderr, "madvise failed: ret: %d, reason: %s\n", ret, strerror(errno)); } usleep(500); } printf("Done....press ^C\n"); pause(); return 0; } Thanks, Pintu